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.
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.
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?
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.
Second, the worm can leave marks and react to marks it left in the past.
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: