test new sname and add save history code into main
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
|
||||
from config import SNAKE
|
||||
import typing
|
||||
import json, os
|
||||
|
||||
# info is called when you create your Battlesnake on play.battlesnake.com
|
||||
# and controls your Battlesnake's appearance
|
||||
@@ -29,10 +30,15 @@ def info() -> typing.Dict:
|
||||
|
||||
# start is called when your Battlesnake begins a game
|
||||
def start(game_state: typing.Dict):
|
||||
SNAKE.clear_history()
|
||||
print("GAME START")
|
||||
|
||||
# end is called when your Battlesnake finishes a game
|
||||
def end(game_state: typing.Dict):
|
||||
os.makedirs(f"{os.path.dirname(__file__)}/history", exist_ok=True)
|
||||
with open(f"{os.path.dirname(__file__)}/history/{SNAKE.__class__.__name__}-{game_state['game']['id']}", "w") as f:
|
||||
json.dump(SNAKE.get_history(), f, ensure_ascii=False)
|
||||
|
||||
print("GAME OVER\n")
|
||||
|
||||
def move(game_state: typing.Dict) -> typing.Dict:
|
||||
|
||||
Reference in New Issue
Block a user