Snake vs Snake, a spin of the classic Snake, is a one minute food competition game between human player and customized AI snake.
- Within 1 minute, user controls a snake to compete for food with the ai snake, and whoever gets the higher points will win.
- Whenever the snake gets the good, it would increase the points and its length by 1 pixel.
- Whenever the snake hits the wall or it's own body, it would shrink and lose 1 points
- To compensate the fairness and also keep the difficulty of the game, AI snake would lose 2 points whenever it hits walls or its own body.
Snake vs Snake is built with JavaScript for DOM manipulation and user interaction.
On the right screen, customized AI snake is running for food to compete with Human player. It's an own-made AI which is not always going for shortest path, and could make some mistakes to make the game fair but challenged.
By clicking play button, user can start the game.
When time is up after 1 minutes, an summary screen would pop out.
Challenge AI and go for the WIN!!!
- Canvas Game Screens
- 2 Snakes and Games
- Middle info section
- Title
- Brief control menu
- Count down timer
- Play button
- Summary Page
- Display results and final score
- Reset button
- AI snake is not perfect, some of corner cases would make it go into corner and loses all points, temporarily implementing the bounce back feature to make the AI bounce back whenever it hits that corner case.
- Body collision logic for AI snake is not perfect as long as it grows super long.
- Key input detection, sometimes when user inputs two directions sequentially in a very short second when the snake is reaching the wall, it could cause the snake to move out of the board.
- For experimental purpose, AI snake moving logic can be improved with algorithm (BFS, DFS, etc), but it would cause the game impossible to beat.
- Improve the collision logic when AI snake grows super long.
- Add a separate instruction menu or page to provide more details of the game.
- Allow user to switch difficulty or change level.
- Add 8-bit background music