DuelSnakesGameState
Attribute | Description |
---|---|
state.snakes |
A list of numpy arrays for the (row, column) coordinates of each snake's body ordered head to tail. Your algo's snake is state.snakes[0] and your opponent's snake is state.snakes[1] . |
state.apples |
A numpy array of the (row, column) coordinates of each apple. |
state.directions |
A numpy array of two integers representing the direction each snake was going on the previous tick. Your snake's direction is state.directions[0] and your opponent's direction is state.directions[1] . |
state.hungers |
A numpy array of two integers representing the hunger of each snake. Your snake's hunger is state.hungers[0] and your opponent's hunger is state.hungers[1] . |
Example
Rendered State
Values in Code
class Algo:
# ...
def take_turn(
self,
state: DuelSnakesGameState,
interface: DuelSnakesInterface
) -> int:
interface.log(state.apples)
# > array([
# [1, 20],
# [12, 4],
# [14, 18],
# [24, 17],
# [22, 10]
# ])
# assume our algo is the blue snake
# VALUES FOR MY SNAKE
interface.log(state.snakes[0])
# > array([
# [23, 5],
# [23, 4],
# [23, 3],
# [23, 2],
# [23, 1],
# [24, 1]
# ])
interface.log(state.hungers[0])
# > 399
interface.log(state.directions[0])
# > 1
# VALUES FOR THE ENEMY SNAKE
interface.log(state.snakes[1])
# > array([
# [15, 18],
# [16, 18],
# [17, 18],
# [18, 18],
# [18, 19],
# [18, 20]
# ])
interface.log(state.hungers[1])
# > 395
interface.log(state.directions[1])
# > 0