SnakeGameState
| Attribute | Description |
|---|---|
state.snake |
A numpy array for the (row, column) coordinates of the snake's body ordered head to tail. |
state.apple |
The (row, column) coordinates of the apple as a numpy array. |
state.direction |
An integer representing the direction the snake was going on the previous tick. |
state.hunger |
An integer representing the hunger of your snake. |
state.time_left |
Seconds until the engine takes this tick's move, as a float. A tick is 50 milliseconds, so it is just under 0.05 when the state reaches you, and it counts down as your algo works: it is measured each time you read it, so read it again rather than keeping the number. Negative once the tick has moved on. |
state.next_tick_time |
The moment time_left counts down to, as a UTC datetime. |
Example
Rendered State
Values in Code
def on_update(state):
SnakeInterface.log(state.snake)
# > array([
# [3, 10],
# [3, 11],
# [3, 12],
# [3, 13],
# [3, 14],
# [4, 14],
# [5, 14],
# [6, 14]
# ])
SnakeInterface.log(state.apple)
# > array([10, 0])
SnakeInterface.log(state.hunger)
# > 401
SnakeInterface.log(state.direction)
# > 3