deviantART facebook google myspace

Roll - Roll Animated Dice

The program animates the throwing of n dice on a command line terminal.

ROLL is a command available in TELEHACK. See URLs:

I’m not certain who authored the source for the roll command, or if the source code is open or closed-source, so I recreated it from scratch.

About the Program

I tried to be as faithful as possible in recreating it. The program should compile on anything with a C compiler that accepts a command line and has stdout and stderr.

The program does not check the screen-size, which is usually 80 characters by 24 or 25 lines. Rolling more than 8 dice doesn't look pretty with 80 characters per line, but most terminals can be configured with more than 100 characters per line. On telehack.com the number of dice is limited to 10.


ROLL without arguments will default to rolling 2 dice.

It will accept one argument. Either an option or a number. Options begin with '-' or '/'. The length of an option is not checked, but all characters must be alphanumeric or '?'. The '?' option gives a brief description. Any characters not in the set described will cause it to exit with a non-zero status. Options, aside from '?' are ignored.

If a number, n, is an integer and 0≤nMAX_NUM_DIES, it will output n flashing dice.

Returns EXIT_SUCCESS (usually zero) for help or a valid number of dice.
Returns EXIT_FAILURE (usually non-zero) on any error.


Unfortunately, on my computer, the command name conflicts with another utility available in mac-ports, so, I renamed the target in the Makefile.

If your character set supports graphic characters, the design of the dice can be modified in roll.h.

The Makefile may need some massaging for DOS, but there shouldn't be any problems compiling. I'm not certain if 8 dice will print correctly. I use ANSI sequences to clear the screen, so you should load ANSI.SYS or ANSI.COM if your command line processor doesn't interpret ANSI sequences.

The ANSI sequences are the least portable portion of the code. This code is isolated in screen.h and screen.c. This program only uses screen_clear() which can be easily updated with appropriate code, a system call to 'clear' or 'CLS.COM', or simply short circuited.




Installation is simple if you have gcc or another compiler installed.

  1. tar xzvf roll-0.2.tar.gz
  2. cd roll-0.2
  3. gedit Makefile # Edit if desired.
  4. make
  5. sudo make install

Michael J. Chappell
February 21, 2017

Friday, 22 December 2017   Michael J. Chappell   Contact me at: mcsuper5@freeshell.org