Giter VIP home page Giter VIP logo

jigsaw-rl's Introduction

Reinforcement Learning - Multiple Games

Overview

This project contains an implementation of a jigsaw puzzle game, a snake game, and multiple learning agents which learn to play both games.

Jigsaw Game

The puzzle game takes an image and generates a simple jigsaw puzzle, similar to below. The jigsaw puzzle is then randomly initialized onto a playing surface, at which point, our learning agent can interact with it.

![Puzzle Sliced](./images/docs/puzzle_sliced.png =250x250)

![Puzzle Initialized](./images/docs/puzzle_shuffled.PNG =250x250)

Running the Code

Before you run the code, you must install all dependencies:

pipenv install -e .

Once the dependencies are installed, you should run the virtual environment with:

pipenv shell

Once the virtual environment is up and running, you can begin the actor critic learning agents by running the following:

python actorCriticRunner.py

This will run the A2C learning agent against the Jigsaw Puzzle game for --T-max training games, updating the NN as it learns.

If you wish to run the agent against the Snake game instead of the Jigsaw Puzzle, you should adjust the environment definition in actorCriticRunner.py.

Human Testing

If you want to run the Jigsaw Puzzle game in human-playable form, you can run:

python humanGameRunner.py

If you want to run the Snake game in human-playable form, you can run:

python .\Environment\Snake\snake.py

Note that the snake game currently runs the pygame implementation, and not the pillow implementation. This means that the human version of the game does not properly test the snake environment. If you wish to test against the true Snake environment, you should run the unit tests.

Unit Tests

There are a handful of unit tests you can use to validate environment behavior. You should adjust unittestsRunner.py to execute the unit tests you wish to run.

Visualizing the Model with TensorBoard

You can use TensorBoard to visualize the model training progress, and monitor several health metrics.

To do this, run the following:

tensorboard --logdir=tf_train  http://localhost:6006/

Then, navigate to http://localhost:6006/

Package Overview

jigsaw-rl . +-- ActionChoosers: contains the action choosers responsible for selecting the action an agent should take +-- Brain: the neural network logic +-- Diagnostics: logging, metrics, etc. +-- Environment | +-- JigsawPuzzle: the Jigsaw Puzzle game | +-- Snake: the Snake game +-- HumanGame: runs the Jigsaw Puzzle environment so that a human can play (instead of a learning agent) +-- Learners: the learning agents +-- tests: unit tests +-- actorCriticRunner.py +-- humanGameRunner.py +-- unittestsRunner.py

How the Game Works

How the Learner Works

Further Reading

flake8 --ignore="E265,E501"

jigsaw-rl's People

Contributors

gupta158 avatar bongiovimatthew avatar bongiovimatthew-microsoft 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.