Instead of controlling the worm directly you build a program for it. The worm can only see a small region around its head, and it has to make decisions based on what it can see. You provide the worm with possible positions that it can encounter, and tell it which turn to take when it encounters one of these positions. These positions are called patterns. For example, this pattern:
Will tell the worm to turn right when it encounters a wall, such as in this situation:
Make a pattern for each situation that you care about, and that will be your program. Each turn the worm goes through the list of patterns you gave it and picks the first pattern that matches what the worm sees. If there is none, it just goes forward.
There is a variety of tools like paint spray for leaving marks in the soil and internal worm memory for tracking things.
There are 30+ levels, most are procedurally generated -- each level features a procedure that generates randomized maps. The goal is to make a program that works well for as many maps generated by the same procedure as possible.
2 GB RAM
2 GB RAM