English • 日本語 (Japanese) • 简体中文 (Simplified Chinese)
This research focuses on the application of reinforcement learning to the development of game strategies, using the classic game of Snake as a case study. The goals of the research include developing AI agents that can effectively play the game, comparing the effectiveness of different reinforcement learning algorithms, and exploring the potential of these techniques in the broader AI domain. Three algorithms, DQN, Double DQN, and Dueling DQN, were used to train the AI agents in a simulated environment, and several performance metrics were set. The research aims to deepen the understanding of the application of reinforcement learning in game strategy development, provide a framework for more complex scenarios, and drive the development of more adaptive AI systems.
You can view the code for different algorithm implementations by switching branches:
-
main: DQN algorithm
-
ddqn: Double DQN algorithm
-
DuelingDQN: Dueling DQN algorithm
Creating an environment from snake-ai-pytorch.yml
file:
conda env create -f snake-ai-pytorch.yml
Activate the new environment: conda activate snake-ai-pytorch
Verify that the new environment was installed correctly:
conda env list
You can also useconda info --envs
For more information, please visit: CONDA User guide > Managing environments
ANACONDA download at https://www.anaconda.com/download
Start ANACONDA.NAVIGATOR
and import snake-ai-pytorch.yml
in Environments
> Import
Run agent.py
using Python:
python agent.py
Screenshot of the game running:
You can view the training results in the results
directory.
-
DQN:AI learns to play Snake Game using Deep Q Learning over 1000 episodes
-
Double DQN:AI learns to play Snake Game using Double DQN over 1000 episodes
-
Dueling DQN:AI learns to play Snake Game using Dueling DQN over 1000 episodes
The design of the Snake game and the implementation of the DQN algorithm references code from the following project:
GitHub - patrickloeber/snake-ai-pytorch
The implementation of Double DQN and Dueling DQN algorithms references code from the following project: