Jev
Asks TypeSafe's Jev for every move. No strategy coded in.
Asks TypeSafe's Jev for every move. No strategy coded in.
Walks one fixed loop through every cell. Can't die; slow to eat.
Same loop, but jumps ahead toward food when the skipped cells are clear of its tail.
| Approach | Score | Ticks | Ticks / food | Result |
|---|---|---|---|---|
| Jev | 0 | 0 | - | playing |
| Hamiltonian cycle | 0 | 0 | - | playing |
| Cycle + shortcuts | 0 | 0 | - | 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.
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.
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.
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:
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
{}
{}
{}