GithubHelp home page GithubHelp logo

snake-cnn-deep-q-learning's Introduction

Snake-CNN-Deep-Q-Learning

This is a repository containing a game of popular Snake that I have built on my own and an AI to play it. AI itself uses Convolutional Neural Network and a method called Deep-Q-Learning to get better at this game. Game is based on a grid of a certain size with a Snake coloured by default in white, apples that it is supposed to eat which are coloured in red and the background is black:

Required libraries:

  • tensorflow (version 1.12.0, recommended tensorflow-gpu and theano for faster computing)
  • keras (version 2.2.2)
  • numpy (version 1.15.1)
  • pygame (version 1.9.4 not sure if higher versions work)
  • matplotlib (version 2.2.3)

My specs:

  • i7-7700HQ Processor
  • 16GB RAM
  • NVIDIA Quadro M1200 4GB graphics card

Training description: Training starts with epsilon set to initial value which then decreases every epoch by some amount until it reaches minimum value. The size of the grid can be changed, but remember that bigger grid will mean slower or no training. The default is set to 10x10. Neural netwo1.1rk is a convolutional network which means that it searches for some features called filters. Input is array with the same size as the grid (this array describes image and every cell in game), which is image of game at certain point in time. This means that AI learns from image. Since however, AI cannot guess which way it is going, it takes on input certain number of previous images (default is 4). When it comes to the rewards: -0.1 (might be too little) is default reward, -1 is for hitting itself or the wall and 2 for eating an apple. AI can take 4 actions corresponding to every direction it can move in.

Results: You can see training results on a 10x10 grid in 'stats.png'. After some more training it reached an average result of 12. Training it to this moment took me around 17 hours.

snake-cnn-deep-q-learning's People

Contributors

jaswar avatar

Stargazers

 avatar  avatar Ethan Crouse avatar Marco Ronzani avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.