Snake

The classic: steer the snake to the food, grow longer with every bite, and avoid the walls and your own tail.

Snake runs in every tool alttab recreates, under the name Data Flow Visualizer. On the Excel sheet the board is a grid of spreadsheet cells, the snake is a line of shaded cells with an arrow on its head, and the food is a red dollar sign. In Excel the formula bar follows the run as it happens, =SNAKE(F7, length=5, points=2): the cell under the head, the length and the score.

How a run works

The snake starts three cells long in the middle of the board, heading right. There is one dollar sign on the board at a time, dropped on a random free cell. Every bite is worth one point, so the score is simply the number of dollar signs eaten. There are no bonus items and no levels.

The board has no fixed size. It fills the space the tool gives it, one cell per 14 pixels, so a larger window gives a longer run before space gets tight. The edges are walls: nothing wraps round to the other side.

Speed comes from the score. The first steps take 150 milliseconds each, every point takes 5 off, and from 15 points onwards the snake moves at its top speed of one cell every 75 milliseconds.

Steering

The game takes one turn per step, and a key that points straight back the way the snake is going is ignored. That is how a tight U-turn goes wrong: press down and then left within one step while heading right, and the left is dropped, because the snake is still heading right. It makes the first turn and carries on, and the second key has to be pressed again after the next step.

Before you start

  • Plan each turn a few cells before the wall, not on it.
  • Keep the body in long straight runs along one side, so the open space stays in one piece.
  • Past 15 points the speed stops climbing. From there on, what gets hard is room, not pace.

More in Salesforce

← All Salesforce exercises