It's snake AI. Sit back and watch If it doesn't work, restart the program and press space. It's not really AI, the code tells the snake to steer itself to the apple.
The original project is Funster10123's, and you should check it out. Right now the snake will cross over itself. Don't worry it'll be fixed. never fixed it ;(