Skip to content

CVanzetta/snake-AI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

11 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ๐ŸŽฎ + ๐Ÿค– Snake Game with AI Agent

This project implements a classic ๐Ÿ game with an ๐Ÿค– agent that uses a ๐Ÿง  neural network to make decisions. The ๐Ÿค– is trained through a ๐Ÿงฌ genetic algorithm and then tested in the ๐ŸŽฎ environment.

Overview ๐Ÿ”

The project consists of three main components:

  1. SnakeGameLogic: Implements the ๐ŸŽฎ mechanics for the ๐Ÿ, including the grid, snake movement, and ๐ŸŽ generation.
  2. Agent: The ๐Ÿค– agent that controls the ๐Ÿ, using a simple ๐Ÿง  neural network to decide movements based on the current ๐ŸŽฎ state.
  3. SnakeGameGUI: Provides a ๐ŸŽจ graphical interface for visualizing the ๐ŸŽฎ and the agent's actions.

How It Works ๐Ÿ› ๏ธ

  • The agent receives a perception of the ๐ŸŒ, which includes โ„น๏ธ about the position of obstacles (โ›”๏ธ), the direction of the ๐Ÿ, and the relative position of the ๐ŸŽ.
  • The agent's decision-making is based on a ๐Ÿง  neural network whose weights are optimized through ๐Ÿงฌ genetic algorithms.

Known Issue โš ๏ธ

An issue is currently open due to difficulties encountered when extending the agent's perception to a range of 2๏ธโƒฃ. When the range_vision is set to 2๏ธโƒฃ, the agent tends to perform poorly, resulting in immediate ๐ŸŽฎ termination with a score of 0๏ธโƒฃ. This issue needs further investigation to understand the underlying cause and to improve the agent's performance with an extended perception range.

Running the Game โ–ถ๏ธ

To run the ๐ŸŽฎ with the current best-trained ๐Ÿค–:

python snake_game_gui.py

The ๐ŸŽฎ will start with the ๐Ÿค– controlling the ๐Ÿ. The objective for the agent is to eat as many ๐ŸŽ as possible without colliding with obstacles (โฌ›๏ธ) or itself.

Opening an Issue ๐Ÿ“

To report problems or contribute to the solution of the existing issue regarding the range_vision, please visit the GitHub Issues page and participate in the discussion.

Requirements ๐Ÿ“‹

  • Python 3.x
  • Tkinter (for the ๐ŸŽจ graphical interface)

Future Work ๐Ÿš€

  • Improve the agent's ๐Ÿง  neural network to effectively handle an extended perception range.
  • Experiment with different ๐Ÿง  network architectures to achieve better performance.
  • Address the current issue with range_vision of 2๏ธโƒฃ, ensuring stability and improved ๐ŸŽฎ behavior.

Contributing ๐Ÿค

Feel free to contribute to the project by opening pull requests or by providing suggestions on the Issues page.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages