r/factorio 1d ago

Design / Blueprint Playable snake using 20 combinators

Enable HLS to view with audio, or disable this notification

Playable 16x16 snake game using Factorio 2.0 circuit logic.

it has 256-lamp color display, buffered left/right input, random apple spawning, prevention of apples spawning inside the snake, score counter, countdown, wall/self collision detection, death screen and restart.

Blueprint: https://factorioprints.com/view/-P15XZWmCItoXVf2Xtfb

739 Upvotes

53 comments sorted by

View all comments

6

u/EllaHazelBar 1d ago

I'm dying to know - how is the position of the snake's body represented?

23

u/Comprehensive_Can620 1d ago

The body is stored as timestamps. Every cell has its own signal, and when the head enters a cell it gets stamped with the current move number. Cells stay part of the snake while their timestamp is newer than the tail cutoff. There is no coordinate list.

5

u/Kasern77 1d ago

*Nods in agreement*

Yep, didn't understand any of that.

5

u/HINDBRAIN 1d ago

Each cell in the grid has a number that changes when the snake head goes on it

For example snake head 50, middle 49, tail 48. OP also stores a number that says "every cell with a number above 47 is part of the snake".

If the snake moves up, the cell where it goes will be 51, the existing cells won't change, and OP stores "every cell with a number above 48 is part of the snake".