Skip to content

Tail Chase

Spectrum · BASIC

Steer a growing snake and leave room for the next turn

10 units

Start with Give the snake a face Browse lessons
Tail Chase course capture
Tail Chase · Spectrum

Eight snacks. One hungry snake. Every meal leaves a little less room for the next turn.

Steer through a 24×16 arena with I up, J left, K down and L right. The snake keeps moving when you release the keys. An opposite direction is ignored, and only the first perpendicular turn before a move is accepted. S starts, R retries and Q quits. Eat eight foods to grow from four cells to twelve and complete the round. The wall and your own body end an attempt.

This game runs in Sinclair BASIC on a stock 48K ZX Spectrum. It uses seven original custom characters and is deliberately silent. The face and fruit have distinct shapes; FOOD and LENGTH show progress.

A twelve-cell snake after eating eight foods, with the completion message above the arena.
Eight foods complete a round; the body stops at length twelve.

Remember the path

We begin with a face and a clocked moving head. Then we store its recent positions so a body follows it around corners. A short shifting array makes that idea visible before we reuse slots in a circular buffer. Eating keeps the departing tail, so the body grows.

Body order and occupancy answer different questions. The ordered positions tell us which cell should leave next; a grid says whether the candidate square is occupied. We keep those two views consistent before combining them into the eight-food round.

There is a complete one-food challenge in lesson six. Two clearly marked diagnostic checkpoints temporarily continue after that food so you can test collision with a longer body. Later lessons restore the ending and build the accepted full round.

Continuous movement, arrays and custom characters have appeared in earlier games. We recall their contracts where needed, and explain circular storage locally. Start a new program; no hidden engine or previous listing is required.

The lessons

  1. Give the snake a face
  2. Keep moving
  3. Choose the next turn
  4. Remember where the head went
  5. Reuse the empty slot
  6. Leave the tail behind
  7. Ask the board
  8. Find another snack
  9. Eat all eight
  10. Keep the game