Giter Club home page Giter Club logo

snakebot-gym's Introduction

snakebot-gym

Implements a OpenAI gym robot snake simulation environment using PyBullet, where the goal is to move a snake robot towards a certain location. You can train Reinforcement Learning agents or define a manual movement function.

Installation

This program was written using Python 3.8.8. Install all depencencies using:

pip install -r requirements.txt

Next, install PyTorch (v1.8.1) using the instructions here.

Usage

The program can be run using the snake.py script. From here, you can use premade manual movement function using:

python snake.py manual

or train a Proximal Policy Optimization (PPO) agent using:

python snake.py train

To test trained models, use:

python snake.py test --model <path_to_model>

If the --model flag is left empty, a random agent is used. For more flag customization, use the -h flag. Several trained modes are located in the models folder. Make sure the snake is of appropriate length (using the snake_length argument).

For a list of all options (training settings etc.), please use:

python snake.py --h

Spaces

State Space

The snake robot is build from a number of Revolute Joints. For a single joint, the state space is defined as:

[angle, speed]

The state of the full environment is defined as the combination of all N joint states, plus the x, y coordinates of the snake head:

[headX, headY, angle1, ... angleN, speed1, ..., speedN]

The reward returned to the agent is defined as the negated distance towards the goal. When the goal is reached (head is within 1 meter of the goal), a reward of 100 is returned.

Action Space

The agent can control the position of each of the robot's N joints. The action space is thus defined as follows:

[pos1, ..., posN]

Useful links

snakebot-gym's People

Contributors

williamcorsel 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.