You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+73-6Lines changed: 73 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Gym Setup Guide
2
2
3
-
## Installation Guide
3
+
###Installation Guide
4
4
First, make sure to follow the install instructions for OpenAI Gym at this [link](https://gym.openai.com/docs).
5
5
6
6
You'll need to have [git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) and [pip](https://pip.pypa.io/en/stable/installing/) installed on your machine.
@@ -10,7 +10,7 @@ Next, make sure to install the proper python packages for this project.
10
10
pip install scipy neat-python argparse
11
11
```
12
12
13
-
## Running the Program
13
+
###Running the Program
14
14
15
15
There are two files used to solve the gym environment: `gym_config` and `gym_solver.py`. `gym_config` contains the config for the neuroevolution process and `gym_solver.py` is the program the creates the neural networks and solves the game. You will need to adjust parameters in both to solve a game.
16
16
@@ -30,10 +30,15 @@ There will be a variable for a game name. This can be any game on the [OpenAI Gy
30
30
To run the program, navigate to the project's directory in your terminal. This will be the same folder you cloned into (OpenAI-Neat). There are several different parameters that you can run the program with.
31
31
32
32
`--max-steps`: The max number of steps to take per genome (timeout)
33
+
33
34
`--episodes`: The number of times to run a single genome. This takes the average fitness score over all episodes for one genome
35
+
34
36
`--render`: Renders the game while the algorithm is learning
37
+
35
38
`--generations`: The number of generations to evolve the network
39
+
36
40
`--checkpoint`: Uses a checkpoint to start the simulation
41
+
37
42
`--num-cores`: The number cores on your computer for parallel execution (not in `--render` mode)
This tells the program to run 50 generations with 10 episodes per species in the population and render the game while the algorithm is learning.
45
50
46
-
## Editing Parameters
51
+
###Editing Parameters
47
52
If you want to change the game, you will need to edit a few parameters. As an example, let's say we want to play Pacman. In order to play Atari games, we must use the ram version. Currently only ram versions are compatible with my program. On the Atari [page](https://gym.openai.com/envs#atari), scroll down and find the name of the ram version of Pacman (`MsPacman-ram-v0`).
48
53
49
54
Open the `gym_solver.py` file and edit the `game_name` parameter so that it is `'MsPacman-ram-v0'`.
My program also gives you the ability to continue a simulation after it finishes. When your simulation finishes, it will generate a `checkpoint` file. If you start a new simulation on the same game, you can use this checkpoint file to pick up where your simulation left off. In the Pacman example, after my simulation finishes, I can run:
89
94
@@ -98,6 +103,68 @@ First, make sure to follow the installation guide for gym (above).
98
103
99
104
Then, make sure you follow the installation instructions for universe at this [link](https://github.com/openai/universe#installation).
100
105
101
-
## Running the Program
106
+
### Running the Program
107
+
108
+
There are two files that are used to solve universe environments: `universe_config` and `universe_solver.py`.
109
+
110
+
You can run the simulation with the same parameters as `gym_solver`
111
+
112
+
`--max-steps`: The max number of steps to take per genome (timeout)
113
+
114
+
`--episodes`: The number of times to run a single genome. This takes the average fitness score over all episodes for one genome
115
+
116
+
`--render`: Renders the game while the algorithm is learning
117
+
118
+
`--generations`: The number of generations to evolve the network
119
+
120
+
`--checkpoint`: Uses a checkpoint to start the simulation
121
+
122
+
`--num-cores`: The number cores on your computer for parallel execution (not in `--render` mode)
123
+
124
+
`universe_solver.py` is initially setup to run with `flashgames.DriftRunners-v0`. You can run it with the following arguments:
`game_name` should be changed to the name of the game you want to simulate.
151
+
152
+
`action_sheet` holds all of the actions that can be taken in the game. A list of actions can be found [here](https://github.com/openai/universe/blob/master/universe/vncdriver/constants.py)
153
+
154
+
`rules` is an array of rules which are basically actions that can't be taken at the same time during one step. For example, the left and right key in a racing game cannot be pressed at the same time.
155
+
156
+
Adjust these paramters according to the game enviroment you choose.
157
+
158
+
Next, open the `universe_config` and edit
159
+
```
160
+
output_nodes = 3
161
+
```
162
+
to be the length of the action sheet array.
163
+
164
+
Also edit
165
+
```
166
+
max_fitness_threshold = 6000
167
+
```
168
+
to an appropriate target fitness score.
102
169
103
-
_TODO_
170
+
*Note* - `universe_solver.py` creates a checkpoint file like `gym_solver.py`
0 commit comments