Getting started: Use nle-ttyplay instead of regular ttyplay to play back recordings

NLE saves recordings of each run in the .ttyrec format. If you are like me and attempt to playback those files with “regular” ttyplay, then you’ll run into some difficulties (and the ttyrec will show up as garbage or without color or other issues). NLE packages their own version of ttyplay that works very well (and even offers color support!).

So after completing the regular starter-kit setup, you can run the random agent with a command like:

cd nethack_baselines/other_examples/
python random_rollouts.py

Exit early (may need to ctrl+c or close the terminal window) after a few iterations complete, then go into your specific log directory created within your other_examples folder (your specific folder / file names will be different from mine):

cd nle_data/20210623-111529_w6kyd95y/
nle-ttyplay nle.60710.0.ttyrec.bz2

And this will let you watch the recording of what your agent performed during that run! :slight_smile:

Good luck, have fun!

4 Likes

Hey,

Yes, NLE saves ttyrec data in a different format than “standard” ttyrec, because it saves outputs as well. We provide nle-ttyrec and nle-ttyplay to record and play this format. The code for these scripts can be found at https://github.com/facebookresearch/nle/blob/master/nle/scripts/ttyplay.py.

Notice that nle-ttyplay has “secret” keyboard commands as well, namely “vi navigation” via h and l. For a full list of commands, check the source code at https://github.com/facebookresearch/nle/blob/master/nle/scripts/ttyplay.py#L66 (notice that the navigation is necessarily limited to jumping to “clear screen” commands, as ttyrecs work incrementally).