OrmaosDocs

Examples

rl-env

A grid world in pure Python and a loop of 20 episodes with a seeded policy, and its recording.

View as Markdown

A reinforcement-learning environment in pure Python, and a loop that runs episodes of it. env.py has GridEnv, a 6 by 6 grid with walls: a courier starts at the depot (0, 0) and walks to a customer at (5, 5). reset() gives the first observation; step(action) gives (observation, reward, done). The reward is 10 at the customer, and otherwise a cost of 0.1 for every cell still to walk. An episode ends at the customer or after 30 steps. run.py runs 20 episodes with a seeded policy that walks towards the customer and sometimes explores.

Run it#

bash
python run.py
rl-env
$ python run.py
20 episodes, mean return -10.55

Recorded#

bash
ormaos run -- python run.py
rl-env
$ ormaos run -- python run.py
20 episodes, mean return -10.55
ormaos: r1 exit 0 in …: 1 Python process, 1969 calls, 0 exceptions
ormaos: saved in .ormaos/r1, next: ormaos tree r1:c1
rl-env
$ ormaos show
r1 exit 0 in …: 1 Python process, 1969 calls, 0 exceptions (0 swallowed, 0 uncaught)
command: python run.py
code: git commit not read (the working directory is not inside a git repository)
never recorded: values, and 20 more kinds of things (`ormaos show --full` lists them with the reason)
next: ormaos tree r1:c1