snake lab
v3 ยท the coder arena
๐Ÿค– write a brain. join a room. beat the other bots.

๐Ÿ Your snake

โš™๏ธ Room settings (when creating)

๐Ÿง  Your bot code

One function is your snake's whole brain. Every tick the game calls it with what your snake can see, and it answers with a direction.

nextMove(state) โ†’ 'UP' ยท 'DOWN' ยท 'LEFT' ยท 'RIGHT'
Whatever you return is the square your head steps into next.
state.me{ body, direction, alive }your snake โ€” the head is body[0]
state.foods[{x, y}, โ€ฆ]apples (fog mode: only the ones you can see)
state.others[{ body, direction, alive }, โ€ฆ]every rival snake
state.board{ width: 60, height: 60 }the world โ€” walls at the edges
state.tick418heartbeat count
returns'UP'one of the four direction strings
Start from:

๐Ÿ•น๏ธ Rooms