bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
episode_gif Namespace Reference

Functions

 parse_kwargs (items)
 read_policy (path)
 read_actions (path)
 caption (frame, text, height=28)
 main ()

Detailed Description

Make a GIF of an episode in a Gymnasium environment.

The algorithms of bitrl train on Gymnasium environments that run on the
bitrl-rest-api server. This script renders an episode of what they learned,
in two ways:

- with --policy FILE, it plays the policy that MaxTabularPolicy::save wrote,
  a state and an action per row, for environments with discrete states such
  as FrozenLake and CliffWalking;
- with --actions FILE, it replays the actions an example wrote, one per row,
  as numbers separated by commas; a first line "# seed N" gives the seed the
  episode was reset with. The environment is the same Gymnasium version, so
  the episode is the same.

Usage:
  python episode_gif.py --env FrozenLake-v1 --kwargs is_slippery=False --policy policy.csv --out run.gif
  python episode_gif.py --env CartPole-v1 --actions episode.csv --out run.gif --title "REINFORCE"

Needs gymnasium, with pygame for the pictures, imageio and Pillow.

Function Documentation

◆ caption()

episode_gif.caption ( frame,
text,
height = 28 )

◆ main()

episode_gif.main ( )

◆ parse_kwargs()

episode_gif.parse_kwargs ( items)

◆ read_actions()

episode_gif.read_actions ( path)

◆ read_policy()

episode_gif.read_policy ( path)