Craps

Craps is played using the traditional rules with simplified betting. The betting may be modified in later versions.

You will start with $100. All bets are for the pass line.

If your coming out roll is 7 or 11 you win.

If your coming out roll is 2, 3 or 12 you lose.

A coming out roll of 4, 5, 6, 8, 9 or 10 sets your point. Once your point is set, you continue to roll until you roll a 7 and crap out, or win by rolling your established point.

Game play continues until you quit or go broke.

Options

Usage: craps [-h] [-v] [-]cash

-h
Print help.
-v
Print version.
cash
cash is your starting bank roll.

If cash is negative the program omits the call to sranddev.

Download

Why?

I was playing around with bsdgames recently and created a menu to start several CLI games. I added a line for craps. I didn't find a craps game.

I seem to recall writing a craps game as a programming excercise in Pascal when I was in highschool. Playing around with the roll command got me to thinking about it. I don't know if I still have the source around anymore.

About the code

C is my preferred language now. So here is a quick attempt. Version 0.2 still has minimal error checking and while I expect it to compile without difficulty it should be considered alpha software. It should work correctly with appropriate input, but has only been tested on OS X 10.15.3 (Catalina).

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

The Makefile may need some massaging for DOS, but there shouldn't be any problems compiling. 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.

©2020 Michael J. Chappell (March 27, 2020)

Saturday, 13 April 2024   Michael J. Chappell   Contact me at: mcsuper5@freeshell.org Made with Emacs