Giter VIP home page Giter VIP logo

snake-rl's Introduction

Snake using RL pylint_badge    test_badge

Reinforcement Learning for the game snake using PyTorch and PyGame. Tested on Ubuntu 20.04.

Install

You can install the source using:

git clone [email protected]:TimReX-22/snake-rl.git

The required dependencies can be install by using pip:

pip install -r requirements.txt

Run

To run a model, you will have to create or modify parameters.json. The JSON file should include the following parameters:

{
  "max_memory": 100000,
  "batch_size": 1000,
  "lr": 0.001,
  "gamma": 0.9,
  "epsilon": 100,
  "model_name": "model/model_score_36_1.pth"
}

model_name should be the relative path to the model file. If you want to train a new model, do not include a model_name in the JSON file. Then you can run the agent using:

python agent.py parameters.json

If you simpy want to play the snake game using your keyboard, your can run the game by:

python snake_pygame/run.py

Incase you get a ModuleNotFoundError, you can most likely resolve it by updating PYTHONPATH with the path to the repo directory:

export PYTHONPATH=$PYTHONPATH:<path to repo>

Credits

The Inspiration for this project stems from this YouTube Video

snake-rl's People

Contributors

timrex-22 avatar

Watchers

Kostas Georgiou avatar  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.