42 lines
1.6 KiB
Python
Executable File
42 lines
1.6 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
# Welcome to
|
|
# __________ __ __ .__ __
|
|
# \______ \_____ _/ |__/ |_| | ____ ______ ____ _____ | | __ ____
|
|
# | | _/\__ \\ __\ __\ | _/ __ \ / ___// \\__ \ | |/ // __ \
|
|
# | | \ / __ \| | | | | |_\ ___/ \___ \| | \/ __ \| <\ ___/
|
|
# |________/(______/__| |__| |____/\_____>______>___|__(______/__|__\\_____>
|
|
#
|
|
# This file can be a nice home for your Battlesnake logic and helper functions.
|
|
#
|
|
# To get you started we've included code to prevent your Battlesnake from moving backwards.
|
|
# For more info see docs.battlesnake.com
|
|
|
|
from server.CreateEnvironmentFile import CreateEnvironmentFile
|
|
from server.Server import Server
|
|
|
|
import os
|
|
|
|
# Start server when `python main.py` is run
|
|
if __name__ == "__main__":
|
|
if os.environ.get("CREATE_ENV_FILE", None):
|
|
CreateEnvironmentFile.load_dotenv({"STORE_GAME_HISTORY": True, "DEBUG": True, "SNAKE": "TemplateSnake", "STORE_IF_WIN_AND_MOVES_ARE_BIGGER_AS": 10})
|
|
|
|
server = Server(
|
|
data_path=os.path.dirname(__file__),
|
|
snake_type=os.environ.get("SNAKE", "TemplateSnake"),
|
|
storage_type=os.environ.get("STORAGE", "LocalStorage"),
|
|
store_game_when_win_and_moves_are_bigger_as=int(os.environ.get("STORE_IF_WIN_AND_MOVES_ARE_BIGGER_AS", 10)),
|
|
debug=os.environ.get("DEBUG_SERVER", False),
|
|
check_tls_security=False
|
|
)
|
|
|
|
if os.environ.get("STORE_GAME_HISTORY", None):
|
|
server.enable_store_game_state()
|
|
|
|
server.run(
|
|
host=os.environ.get("HOST", "0.0.0.0"),
|
|
port=int(os.environ.get("PORT", "8000")),
|
|
debug=bool(os.environ.get("DEBUG", False))
|
|
)
|