All Projects → Elmar999 → snake-reinforcement-DNN

Elmar999 / snake-reinforcement-DNN

Licence: MIT License
Developing a deep neural network to play a snake game

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to snake-reinforcement-DNN

Q-Snake
A Q-learning web visualizer for Snake built with React
Stars: ✭ 34 (+183.33%)
Mutual labels:  snake-game
MaRLEnE
Machine- and Reinforcement Learning ExtensioN for (game) Engines
Stars: ✭ 47 (+291.67%)
Mutual labels:  deep-reinforcement-learning
ddrl
Deep Developmental Reinforcement Learning
Stars: ✭ 27 (+125%)
Mutual labels:  deep-reinforcement-learning
robustnav
Evaluating pre-trained navigation agents under corruptions
Stars: ✭ 18 (+50%)
Mutual labels:  deep-reinforcement-learning
playing-mario-with-deep-reinforcement-learning
An implementation of (Double/Dueling) Deep-Q Learning to play Super Mario Bros.
Stars: ✭ 55 (+358.33%)
Mutual labels:  deep-reinforcement-learning
Deep-RL-agents
No description or website provided.
Stars: ✭ 27 (+125%)
Mutual labels:  deep-reinforcement-learning
Deep-Reinforcement-Learning-CS285-Pytorch
Solutions of assignments of Deep Reinforcement Learning course presented by the University of California, Berkeley (CS285) in Pytorch framework
Stars: ✭ 104 (+766.67%)
Mutual labels:  deep-reinforcement-learning
Object-Goal-Navigation
Pytorch code for NeurIPS-20 Paper "Object Goal Navigation using Goal-Oriented Semantic Exploration"
Stars: ✭ 107 (+791.67%)
Mutual labels:  deep-reinforcement-learning
deep-rl-quadcopter
Implementation of Deep Deterministic Policy Gradients (DDPG) to teach a Quadcopter How to Fly!
Stars: ✭ 17 (+41.67%)
Mutual labels:  deep-reinforcement-learning
DRL DeliveryDuel
Deep Reinforcement Learning applied to a modern 3D video-game environment called Delivery Duel.
Stars: ✭ 30 (+150%)
Mutual labels:  deep-reinforcement-learning
snake
Basic Snake Game in TypeScript
Stars: ✭ 25 (+108.33%)
Mutual labels:  snake-game
FLEXS
Fitness landscape exploration sandbox for biological sequence design.
Stars: ✭ 92 (+666.67%)
Mutual labels:  deep-reinforcement-learning
dqn-lambda
NeurIPS 2019: DQN(λ) = Deep Q-Network + λ-returns.
Stars: ✭ 20 (+66.67%)
Mutual labels:  deep-reinforcement-learning
Deep-Quality-Value-Family
Official implementation of the paper "Approximating two value functions instead of one: towards characterizing a new family of Deep Reinforcement Learning Algorithms": https://arxiv.org/abs/1909.01779 To appear at the next NeurIPS2019 DRL-Workshop
Stars: ✭ 12 (+0%)
Mutual labels:  deep-reinforcement-learning
rl pytorch
Deep Reinforcement Learning Algorithms Implementation in PyTorch
Stars: ✭ 23 (+91.67%)
Mutual labels:  deep-reinforcement-learning
deep reinforcement learning gallery
Deep reinforcement learning with tensorflow2
Stars: ✭ 35 (+191.67%)
Mutual labels:  deep-reinforcement-learning
Deep-Q-Networks
Implementation of Deep/Double Deep/Dueling Deep Q networks for playing Atari games using Keras and OpenAI gym
Stars: ✭ 38 (+216.67%)
Mutual labels:  deep-reinforcement-learning
Reinforcement Learning
Research repo of RL
Stars: ✭ 20 (+66.67%)
Mutual labels:  deep-reinforcement-learning
Deep-rl-mxnet
Mxnet implementation of Deep Reinforcement Learning papers, such as DQN, PG, DDPG, PPO
Stars: ✭ 26 (+116.67%)
Mutual labels:  deep-reinforcement-learning
DRL graph exploration
Autonomous Exploration Under Uncertainty via Deep Reinforcement Learning on Graphs
Stars: ✭ 53 (+341.67%)
Mutual labels:  deep-reinforcement-learning

Snake game with Deep Neural Network

Introduction

AI for snake game trained from the states of environment using Neural Network. Neural Network is implemented using Keras functional API, that makes it easy to experiment with different architectures. The input of Neural Network is the state elements of our environment.
We have 8 states in this game:

  • Player neighbour on above (1-yes, 0-no)
  • Player neighbour on down (1-yes, 0-no)
  • Player neighbour on right (1-yes, 0-no)
  • Player neighbour on left (1-yes, 0-no)
  • Player position over x-axis
  • Player position over y-axis
  • Food position over x-axis
  • Food position over y-axis

Data

Data has always been one of the most important things in AI related problems. In order to teach the player to make an action in each state, data should be well gathered. In order to have a good data I did not play the game randomly but with user-handling keyboard. So I played the game for about 300 episodes and more data generated later on automatically. Reward was given when player eats food and gathered data.

Model

Neural Network input is consist of 8 neurons, which are showed above. Since we have 4 choices in each state (up, down, left, right), the number of output neurons is 4. The architecture of the neural network is not complex, I tried with two hidden layers but you can experiment with other architectures.

Installation

First of all, you need to check if you have all required packages to launch the program. If not then install requirements.

$ cd ../snake_ai_reinforcement
$ pip3 install -r requirements.txt

Then cd into game directory and run python3 main.py -h to see usage and options.

$ cd game
$ python3 main.py -h

Usage

usage: main.py [-h] [--generate_data] [--episode_number FLAG_NB_EPISODE]
               [--train] [--load_data FLAG_LOAD_DATA]
               [--model_path FLAG_MODEL_PATH] [--run_game]

Options

  • --generate_data - user should play the game to generate data
    • --episode_number NB_EPISODE - specify number of episodes that the game will be played.
  • --train - train a model with Neural Network
  • --lad_data load_data_path - if you have several generated data you can specify the data that you want to train on
  • --run_game - run the game
    • --model_path model_path - specify which model (.h5 file) that game will be used during prediction time

Usage example

generating data

$ python3 main.py --generate_data --episode_number 300

train model over generated data

$  python3 main.py --train --load_data ../game/snake_data.npy

run game with trained model

$ python3 main.py --run_game --model_path ../game/snake_model.h5

Game Demo

Bot is playing on his own.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].