Intelligent Snake

This is the final version of the snake game. I have implemented a* algorithm in the intelligent snake (it is much clever than the previous ones). There are three kinds of snakes. You can choose the color and start position of any snake yourself. The different types of snake are :

Human Snake

This is a human-controlled snake. It can be created by pressing ‘h’ during gameplay. You have to control the human snake from your keyboard .

Computer Snake

It is slightly intelligent snake. It is the remain of the previous version of the game. It can still play quite well. But, the algorithm is quite weak compared to the “intelligent snake”. You can create a computer snake by pressing “c” during gameplay.

Intelligent Snake

It is the most advanced snake of all. It uses a* algorithm to find it’s path to the food. If there is no path (like when the body of snake is forming a loop around the food and preventing itself from going towards food) then it will use the algorithm of “computer snake” to find it’s path until a clear route to the food is found.


Snake game version 3.0 screenshot
Snake game version 3.0 screenshot

All of the snakes can warp around the platform. The computer snake is aware of this, the human snake can be aware of this . But unfortunately, the intelligent snake is not aware of this. Anyway, it can survive about 20-40 foods in a 40×40 board. I will try to make the snake play a perfect game in later days. If you encountered any errors in the program, please contact me. I created the game using python 3.3 and pygame 1.9.2

You can view the sources file in it’s repository.

0 0 votes
Article Rating
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x