Cyborg Earthworm is a "Snake" automation game. The worm follows the rules of the famous Snake game, and you can program it. Develop a strategy and let the worm follow it without your involvement. The worm can see a small region around its head, and you provide it with possible situations that it can encounter.

Post news Report RSS Making a Snake AI with visual rules

Why I'm building Cyborg Earthworm and why it's interesting.

Posted by on

It really annoys me that when I play Snake I can't hit the damn fruits because the snake is going too fast. I also have an obsessive dream to eat so many fruits that my snake fills all available space. Sadly, it would be too tedious to make that dream a reality. Besides, one mistake and you have to start over.

The natural solution for this predicament would be to automate it, and the most intuitive way is to provide the snake with all possible positions that it can encounter, telling it which turn it should take in each case. The computer will be able to use these positions to play the game automatically, so I can just sit back and watch.

turn left when there is food

Ok, that's not a snake, that's a worm, but never mind that. Snakes are too boring anyway.

A couple of things become evident immediately:
1. There are too many positions.
2. You don't want to go and specify every single tile of a large position. That's too much work.

To circumvent that, we will restrict positions to only a small region around the worm's head. Furthermore, we want to tell the computer that we don't care about some tiles.

simplified position


Now the problem is that you can't detect the food if it's far away. It's not a big problem, though, because you will have to decide how to lay out the worm when it's long anyway. So you might as well think about how it will traverse the space searching for food. Will it go in circles or zigzags?

travelling in zigzags

To make this type of strategizing possible, I made two tools.

First, the worm carries around a piece of memory that it can use to make decisions and update in certain situations.

using memory

pattern involving memory


setting memory

Second, the worm can leave marks and react to marks it left in the past.

using markup

a pattern that involves markup


setting markup


There are more tools, but these are the ones that make programming feasible.


I'm running a demo on Steam, feel free to check it out:

Store.steampowered.com

Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: