Git Product home page Git Product logo

gym-short-corridor's Introduction

gym-short-corridor

This is an environment built out of the Example 13.1 "Short corridor with switched actions" from Reinforcement Learning book, 2nd ed. 2018.

Example 13.1

There are four states. The goal is to reach the goal state "G" on the right. The reward is -1 for every step. You start at state "S" - first state on the left. Second state acts in reverse - so if you take a step left you end up going right, and if you take a step right you end up going left. The state is unknown to you - you will always get 0.

Installation

cd gym-short-corridor
pip install -e .

Usage

Here is an example random policy that shows how to exercise the environment:

import gym
import gym_short_corridor
import random
env = gym.make("ShortCorridorEnv-v0")

state = env.reset()
env.render()

while True: 
    action = env.action_space.sample()
    step = "left" if action == 0 else "right"
    print("Try to go " + step)
    state, reward, done, _ = env.step(action) 
    env.render()

    if done:
        break

Sample run of the above may produce the following:

[x]{ }[ ][ ]
Try to go left
[x]{ }[ ][ ]
Try to go right
[ ]{x}[ ][ ]
Try to go right
[x]{ }[ ][ ]
Try to go right
[ ]{x}[ ][ ]
Try to go right
[x]{ }[ ][ ]
Try to go right
[ ]{x}[ ][ ]
Try to go left
[ ]{ }[x][ ]
Try to go right
[ ]{ }[ ][x]

Here "x" is the current true state of the environment (not known to the agent - which only sees one state). The "{ }" indicates a state in which actions are reversed. The rightmost state is the terminal state.

gym-short-corridor's People

Contributors

drozzy avatar

Stargazers

 avatar Kianté Brantley avatar Ivan Lee avatar Vasileios Lioutas avatar

Watchers

 avatar James Cloos 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.