change to new code of battlesnake

This commit is contained in:
2024-04-01 01:41:06 +02:00
parent 11c1adf96c
commit a2f8f5b800
6 changed files with 134 additions and 136 deletions
+48
View File
@@ -0,0 +1,48 @@
# 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
import typing
import server_logic
# info is called when you create your Battlesnake on play.battlesnake.com
# and controls your Battlesnake's appearance
# TIP: If you open your Battlesnake URL in a browser you should see this data
def info() -> typing.Dict:
print("INFO")
return {
"apiversion": "1",
"author": "daniel156161", # TODO: Your Battlesnake Username
"color": "#00ff00", # TODO: Choose color
"head": "default", # TODO: Choose head
"tail": "default", # TODO: Choose tail
}
# start is called when your Battlesnake begins a game
def start(game_state: typing.Dict):
print("GAME START")
# end is called when your Battlesnake finishes a game
def end(game_state: typing.Dict):
print("GAME OVER\n")
def move(game_state: typing.Dict) -> typing.Dict:
next_move = server_logic.choose_move(game_state)
print(f"MOVE {game_state['turn']}: {next_move}")
return {"move": next_move}
# Start server when `python main.py` is run
if __name__ == "__main__":
from server import run_server
run_server({"info": info, "start": start, "move": move, "end": end})