Get the height of the arena. This is constant and does not change during a game.
Get the (width, height) of the arena. This is constant and does not change during a game.
Get the width of the arena. This is constant and does not change during a game.
Get the number of CPU cycles executed per tick. This is constant.
Get the number of CPU cycles that have already executed in the current tick.
Get the current position of the head of the snake.
Get the current tick. Starts at 0.
Get the current health of the snake. The maximum health is 100. The health decreases by 1 each tick.
If the health of a snake ever reaches zero, it will die. A snake can gain health by eating food.
Food increases health. Poison damages health.
Get the id of the snake. This is constant, except after a split
, where the new snake will have a new id.
Get the length of the snake.
Get the id of your team. This is constant.
A leap is an additional move that can occur at most once every 2 ticks.
It must only be called during a tick in which a move has already been performed, and
a leap was not performed during the current or previous tick.
Performing a leap will consume the last body part of this snake, which will drop on the floor as poison.
Move immediately in the current direction. A snake must move once per tick.
If the snake isn’t manually moved, it will be automatically called at the end of the tick.
Note that this takes effect on the exact CPU cycle it is called. This means that all
snakes do not necessarily move at the same time (you can pick when during the tick the move occurs).
View a certain position in the arena.
Get a random value between the min (inclusive) and max (exclusive).
The returned value is deterministic based on the current state of the game and the initial seed.
Sets the direction of the snake. This is the direction the snake will move next.
Sleep (do nothing) for a specific number of cycles.
Sleep (do nothing) for all remaining CPU cycles in the current tick.
Logs a message. The maximum length is 50. Any message longer than this will be truncated.
A snake can send at most 10 logs per tick. Any additional logs will be ignored.
If the snake has a length of at least 9, it is eligible to split into two.
The snake is split into three parts (the middle is rounded up, the rest down). The first part will remain as
the original snake. The middle part will be lost and turn into poison. The end will become a new
snake. The snake runtime will be forked, and both new snakes will continue to run independently.
You can use get_id
to determine which snake is now running.
Kill the snake immediately. All parts of the snake will turn into poison.