33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
import typing
|
|
|
|
|
|
class Snake:
|
|
|
|
SNAKES: typing.Dict[str, typing.Type["Snake"]] = {}
|
|
|
|
def __init_subclass__(cls) -> None:
|
|
cls.SNAKES[cls.__name__] = cls
|
|
|
|
def info(self) -> typing.Dict:
|
|
'''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
|
|
'''
|
|
raise NotImplementedError()
|
|
|
|
def start(self, game_state: typing.Dict) -> None:
|
|
'''start is called when your Battlesnake begins a game'''
|
|
raise NotImplementedError()
|
|
|
|
def end(self, game_state: typing.Dict) -> None:
|
|
'''end is called when your Battlesnake finishes a game'''
|
|
raise NotImplementedError()
|
|
|
|
def move(self, game_state: typing.Dict) -> typing.Dict:
|
|
'''move is called on every turn and returns your next move
|
|
Valid moves are "up", "down", "left", or "right"
|
|
See https://docs.battlesnake.com/api/example-move for available data
|
|
'''
|
|
raise NotImplementedError()
|