How to program a computer if you are a child/Your turn

Here is the scenario of a little game I programmed when I was twelve or thirteen, a long time ago:

A variant is possible for two players who compete in the same room, each with his or her snake.