Giter Site home page Giter Site logo

rl-dqn-snake-game's Introduction

Reinforcement Learning Snake Game - DQN

By Sudharsan Ananth

Table of Contents
  1. Introduction
  2. Dependencies
  3. Prerequisites
  4. Run the game
  5. License

Introduction

In this project I have created a DQN agent to train in a snake game environment. The objective of the snake is to collide(eat) all the food that is placed randomly in the environment.

Untrained agent.

untrained snake agent

Trained agent.

trained snake agent

Dependencies

This project is built with the below given major frameworks and libraries. The code is primarily based on python. And the environment is created using Anaconda.

Prerequisites

  1. Python 3.7 (skip if downloading conda)
  2. Conda (Either miniconda or Ananconda)

Run the game

Simply clone the repo cd into the right directory and run agent using the below commands. Step-by-Step instructions given below. Simply change the directory and run agent.py from the directory RL_car_game. You will be able to see the agent training and getting better in minutes.

  1. Clone the repository using

    git clone https://github.com/sudharsan-007/RL-DQN-Snake-Game.git
  2. cd into the directory RL-DQN-Snake-Game

    cd RL-DQN-Snake-Game
  3. Recommended: create a conda environment

    # We require python>=3.7
    conda create -n rl_snake_game python=3.7 numpy matplotlib 
    conda activate rl_snake_game
  4. Install pygame

    pip install pygame
    pip install ipython
    pip install matplotlib
  5. Install pyTorch (CPU verison). Please refer pytorch website to get right version for GPU.

    # https://pytorch.org/get-started/locally/
    conda install pytorch torchvision torchaudio cpuonly -c pytorch
  6. If the above code does not work for you try this(skip this step 5 worked).

    pip3 install torch torchvision torchaudio
  7. Run agent.py from this directory and from inside this environment

    python agent.py
  8. To run the environment without Reinforcement Agent and the agent controllable by WASD keys

    python snake_game.py

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

rl-dqn-snake-game's People

Contributors

sudharsan-007 avatar

Stargazers

 avatar

Watchers

 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.