← Castle

JevSnake

racepaused
seed-
jev ms-
tick/s-

Tally

ApproachScoreTicksTicks / foodResult
Jev00-playing
Hamiltonian cycle00-playing
Cycle + shortcuts00-playing

Each snake fades from head to tail. All three start from the same seed, so their first food lands in the same cell. After that the food depends on where each body lies. Fewer ticks per food means a more direct route. The two cycle snakes always fill the board; the question is how fast.

How they play

Jev

Every tick the browser describes the board as text: the body from head to tail, the food, and for each direction where it leads, whether it hits a wall or the body, and which safe moves would be left after it. That goes to Jev as one typed question: pick a move. Jev returns the pick and a probability for each option. Nothing in the code plans a route, so any strategy you see is Jev's judgment reading that state. When only one move is safe, the question becomes a yes/no on taking it.

What a System One model is · TypeSafe

Hamiltonian cycle

A Hamiltonian cycle is a closed path that visits every cell exactly once and ends next to where it began. On a board with an even number of rows you can always draw one: here it runs along the top row, snakes back and forth through the rest, and climbs the left column home. The snake just follows it forever. Its body is always a stretch of the loop and its head only ever moves into the cell after it, so the head never catches the tail and it can't die. The price: food behind the head means walking almost the whole loop, about half the empty cells per meal on average.

Hamiltonian path and cycle (Wikipedia)

Cycle + safe shortcuts

Number the cells 0 to 63 in the order the loop visits them. The plain cycle snake's body always sits on a run of those numbers ending at the head, and it survives because the cells ahead of its head, up to its tail, are empty. The shortcut snake keeps that rule but leaves gaps: each tick it looks at its neighbouring cells and measures how far ahead each one is along the loop. It takes the furthest one that:

  1. is safe right now,
  2. doesn't skip past the food, and
  3. leaves at least 3 empty loop cells between it and the tail. One covers the tail staying put while the snake grows; the rest is slack.

Anything skipped was already empty, so the body is still in loop order, and following the plain loop from any point stays safe. The snake keeps the cycle's guarantee to fill the board and cuts across it whenever the way is clear. Early, with a short body, it eats about 3× faster. Late, the gaps it left behind make it lap the board for stray food, and its lead over the plain cycle shrinks.

Nokia 6110 Part 3 – Algorithms, by John Tapsell (the algorithm this one follows) · the code

Jev's decision

move-
question-
confidence-
model-

State sent

{}
Jev request
{}

Raw response

{}