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.
Usage: craps [-h] [-v] [-]cash
If cash is negative the program omits the call to sranddev.
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.
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).
Version 0.3 has been updated to compile under Linux. I just added a define for sranddev to seed srand() from time(), since it was missing on Linux. I didn't make any other relevant changes to the C code. I also fixed a bug in the Makefile, so the man page should install correctly.
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.
©2024 Michael J. Chappell (October 6, 2024)
Sunday, 6 October 2024 Michael J. Chappell Contact me at: mcsuper5@freeshell.org