This is an OpenAI Gym environment for reinforcement learning in a block world setting using PyReason as a default simulator but there is an option to use simulator other than PyReason.
- There are 5 blocks of certain color, shape and cost kept on a table.
- Possible colors: [Red, Green, Blue], Possible shapes: [vertical, horizontal]
- Cost of block is dependent on the color -> {Red: 2, Green: 4, Blue: 6}
- RL policy is independent of the cost.
- Robot arm will work with these blocks.
There are 3 types of actions taken step by step by the simulator:
Restarts the simulator by bringing it to a state where environment is not aware of the properties of 5 blocks.
Environment is provided with properties of the available 5 blocks i.e. color, shape.
The objecive of the game is to build a legal bridge structure using the blocks on the table in such a way that it satisfies certain constraints:
- There are 2 base slots: [h1], [h2]
- There is 1 top slots: [h3]
- Base slots can be only filled by vertical blocks.
- Top slot can be only filled by horizontal block.
- Green block cannot touch blue block, i.e. h3 touches h1 and h2. h1 and h2 does not touch each other.
A reward is calculated as follows:
- If block is placed in a legal slot, then reward of
+1
is given. - If block is placed in a illegal slot, then reward of
-2
is given. - If house structure is built completely then reward of
+10
is given. - If house structure is incomplete even if number of available blocks is less than number of remaining slots, then reward of
-10
is given.
Make sure latest version pyreason==2.0.1
has been installed using the instructions found here
Clone the repository, and install:
git clone https://github.com/jaikrishnap98/pyreason-gym-bridge-world
To run the environment and get a feel for things you can run the test_legal_bridge.py
file which will perform actions in the bridge world.
You can change the actions in the script according to your requirement.
If you want to use PyReason as a simulator, set macro PYREASON_SIMULATOR
= True otherwise set it to False and provide your own implementation in the other_simulator.py
python test_legal_bridge.py
This Bridge World scenario needs a graph in GraphML format to run. A graph file has **already been generated** in the [graphs folder](pyreason_gym/pyreason_bridge_world/graph/bridge_world_graph.graphml/).
This is an OpenAI Gym custom environment. More on OpenAI Gym:
1. [Documentation](https://www.gymlibrary.dev/)
2. [GitHub Repo](https://github.com/openai/gym)
The interface is just like a normal Gym environment. To create an environment and start using it, insert the following into your Python script. Make sure you've [Installed](#installation) this package before this.
A Tutorial on how to interact with gym environments can be found [here](https://www.gymlibrary.dev/)