A snake game that uses AI to find food. Imagine if other animales did the same thing!
source: https://medium.com/@nancy.q.zhou/teaching-an-ai-to-play-the-snake-game-using-reinforcement-learning-6d2a6e8f3b1c
- Implement the game and setup the environment
- Create the Neural Network
- Implement and Train the Agent
- NumPy: A python library used for working with arrays
- Matplotlib: Helps plot and create visualizations of data
- Pytorch: A machine learning framework that helps create neural networks
- Pygame: Python module designed for video games
- Create a model to train the network
- Choose between 2 models used for reinforcement learning
- Q - Learning or the Markov Decision Process (MDP)
- Finds teh best course of action given current state of the agent through trial and error
- It does so by randomizing its actions, and repeating what works
- Q stands for quality
- If the snake repeatedly dies from hitting the walls at a certain point, the agent will learn that going straight towards walls does NOT lead to best course of action
- Next time, it will probably turn before going directly into wall
- Instead of neural network, Q-learning uses a table that calculates teh maximum expected future reward for each action at each state.
- One dimension measures possible actions(the agent's methods to interact and change its environment) while the other dimension is possible states
- The agent will choose the action with highest reward
- When a table is not very efficient, then that is when deep Q-learning comes
- Same as Q-learning but with neaural network instead of a table
- It uses Belleman equation - used in this code