pyttyplay: a NetHack ttyrec player in Python

Dion Moult

2024-12-10

If you want to record activity in a terminal, you can store it in a .ttyrec format. This is much more efficient than a video, and captures exactly all of the characters and escape events occuring in the terminal. When playing it back, it relies on the ability of your own terminal to recreate the experience.

ttyrec is commonly used to record NetHack games, which may span many hours or days of recording. A more modern alternative is asciicast, used by asciinema, which although it contains more information, is extremely inefficient due to the storage of everything as UTF-8 encoded JSON strings. ttyrec by itself is very spartan, including nothing but the binary raw terminal characters interspersed with headers denoting the timestamp. Notably missing are things like terminal size, full recording duration, encoding, custom user colourschemes, etc.

There are a number of existing ttyrec players out there, but none seem to have all the features I'm looking for, so I wrote another one. Check out the Github pyttyplay repository to download and run.

Here's what it looks like in action:

pyttyplay playing a ttyrec of a NetHack game by elenmirie

Features

pyttyplay playing a ttyrec of a NetHack game by disperse showing DEC graphics

If you want to try it out on some ttyrecs, you can download NetHack recordings from the HardFought ttyrec server.

If there are bugs, that's probably because it's something to do with a VT100 command that I don't fully understand. If you want to solve it, you might want to investigate this list of VT100 escape codes, or XTerm control sequences and ANSI colour codes.

Comments

If you have any comments, please send them to .