Temporal Vagabonds Rolling Dice

I've written a dice simulation for every programming language I've endeavoured to learn. In the future I will add a variety of such programs and scripts.

Javascript Die Roller

This is a simple javascript die roller. Just adjust the settings for the number of dice and the die type and click the roll button.

Simple Dicer

This is just a program when in a fit of nostalgia for the BASIC of my youth I wrote in 2000 while messing around with Chipmunk BASIC on an Apple Macintosh. The kind of BASIC that has line numbers, goto and gosub commands, and stuff like that. I found a BASIC interpreter on the internet and gave that a try. Since Chipmunk BASIC is a clone of the implementation of BASIC found on the Apple II line of computers this program should run fine in that environment or on emulations of the Apple II or what have you. It'll need some modification to work in other versions of BASIC but it'd be a trivial task.

Okay, I wrote the above before I actually tried to adapt it to an actual vintage computer. The task wasn't as trivial as I'd thought. The program actually required modifications to every section of the code. Some of which were not immediately obvious until I started fiddling with it. I don't know it this version will work on an Apple II as written. I've only really spent about 9 months in 1988 writing code on an Apple IIe. It'll work in Chipmunk BASIC and that's all that can be said.

Chipmunk Basic

10 rem ********************************** 20 rem * Simple Dicer Program Version 1 * 30 rem * Written by Philip Hightower * 40 rem * in December 2000. * 50 rem ********************************** 60 sides = 6 70 r = 3 80 gosub 500 90 a$ = inkey$ 100 if a$ = "q" then end 110 if a$ = "e" then gosub 850 120 if a$ = "w" then gosub 690 130 if a$ = "r" then gosub 910 140 if a$ = "c" then input "# of rolls> ";r 150 if a$ = "z" then print "Current die =";r;"d";sides 160 if a$ = "x" then gosub 430 170 if a$ = "v" then input "# of sides> ";sides 180 if a$ = "m" then gosub 500 190 if a$ = "1" then r = 1 200 if a$ = "2" then r = 2 210 if a$ = "3" then r = 3 220 if a$ = "4" then r = 4 230 if a$ = "5" then r = 5 240 if a$ = "6" then r = 6 250 if a$ = "7" then r = 7 260 if a$ = "8" then r = 8 270 if a$ = "9" then r = 9 280 if a$ = "0" then r = 10 290 if a$ = "a" then sides = 2 300 if a$ = "s" then sides = 3 310 if a$ = "d" then sides = 4 320 if a$ = "f" then sides = 6 330 if a$ = "g" then sides = 7 340 if a$ = "h" then sides = 8 350 if a$ = "j" then sides = 10 360 if a$ = "k" then sides = 12 370 if a$ = "l" then sides = 20 380 if a$ = ";" then sides = 30 390 if a$ = "'" then sides = 32 400 if a$ = "b" then sides = 50 410 if a$ = "n" then sides = 100 420 goto 90 430 rem *********** Roll dice 440 dieroll = 0 450 for i = 1 to r 460 dieroll = dieroll+rnd(sides)+1 470 next i 480 print r;"d";sides;"=";dieroll 490 return 500 rem ************* Menu 510 print 520 print "1...0 - Specify Number of Rolls" 530 print "a - Set to d2 s - Set to d3" 540 print "d - Set to d4 f - Set to d6" 550 print "g - Set to d7 h - Set to d8" 560 print "j - Set to d10 k - Set to d12" 570 print "l - Set to d20 ; - Set to d30" 580 print "' - Set to d32 b - Set to d50" 590 print "n - Set to d100" 600 print 610 print "c - Change Number of Rolls v - Change Number of Sides" 620 print "z - Display Current Die x - Execute a Die Roll" 630 print "w - Roll an Exploding Die e - Roll Singlets" 640 print "r - Roll Fudge Dice" 650 print 660 print "q - Quit Program m - Display Redisplay Menu" 670 print 680 return 690 rem ************* Exploding Dice 700 dieroll = 0 710 countr = r-1 720 for i = 1 to countr 730 dieroll = dieroll+rnd(sides)+1 740 next i 750 rollq = rnd(sides)+1 760 if rollq = sides then print "Exploding" : dieroll = dieroll+rollq 770 rem *** Strange sequence of if...then statements because Chipmunk BASIC 780 rem *** doesn't seem to like else operators on multiple statement if...then 790 if not (rollq = sides) then dieroll = dieroll+rollq 800 rem *** statements 810 if not (rollq = sides) then goto 830 820 goto 750 830 print "Exploding die ";r;"d";sides;"=";dieroll 840 return 850 rem ************ Singlet Rolls 860 print "Singlets for ";r;"d";sides ":" 870 for i = 1 to r 880 print "Dice ";i;"=";rnd(sides)+1 890 next i 900 return 910 rem ************ Fudge Dice 920 input "Enter # of Fudge Dice to roll> ";fudge 930 print "Rolling ";fudge;" Fudge dice." 940 for i = 1 to fudge 950 diefud = rnd(6)+1 960 if diefud = 1 or diefud = 2 then print "+" 970 if diefud = 3 or diefud = 4 then print "[]" 980 if diefud = 5 or diefud = 6 then print "-" 990 next i 1000 print 1010 print "End of Fudge Roll." 1020 return

Tandy Color Computer

This version of Simple Dicer will run on a Tandy Color Computer. Modifying the program to work on the CoCo was less trivial than I had imagined. The menu had to be redone to fit into a 32x16 text screen. Input prompts had to be shortened; in some cases drastically. The RND calls had to be chanced to accommodate a small difference in the way that function is implemented in the two versions of BASIC. Everything had to be changed to uppercase and comment lines had to be modified to be more aesthetically pleasing on the Color Computer's display. All in all, I think it came out pretty well. 10 REM *********************** 20 REM * SIMPLE DICER 1B * 30 REM * BY PHILIP HIGHTOWER * 40 REM * DEC 2000 / MAR 2011 * 50 REM *********************** 60 SIDES = 6 70 R = 3 80 GOSUB 500 90 A$ = INKEY$ 100 IF A$ = "Q" THEN END 110 IF A$ = "E" THEN GOSUB 820 120 IF A$ = "W" THEN GOSUB 690 130 IF A$ = "R" THEN GOSUB 880 140 IF A$ = "C" THEN INPUT "# OF DICE";R 150 IF A$ = "Z" THEN PRINT "CURRENT DIE =";R;"D";SIDES 160 IF A$ = "X" THEN GOSUB 430 170 IF A$ = "V" THEN INPUT "# OF SIDES";SIDES 180 IF A$ = "M" THEN GOSUB 500 190 IF A$ = "1" THEN R = 1 200 IF A$ = "2" THEN R = 2 210 IF A$ = "3" THEN R = 3 220 IF A$ = "4" THEN R = 4 230 IF A$ = "5" THEN R = 5 240 IF A$ = "6" THEN R = 6 250 IF A$ = "7" THEN R = 7 260 IF A$ = "8" THEN R = 8 270 IF A$ = "9" THEN R = 9 280 IF A$ = "0" THEN R = 10 290 IF A$ = "A" THEN SIDES = 2 300 IF A$ = "S" THEN SIDES = 3 310 IF A$ = "D" THEN SIDES = 4 320 IF A$ = "F" THEN SIDES = 6 330 IF A$ = "G" THEN SIDES = 7 340 IF A$ = "H" THEN SIDES = 8 350 IF A$ = "J" THEN SIDES = 10 360 IF A$ = "K" THEN SIDES = 12 370 IF A$ = "L" THEN SIDES = 20 380 IF A$ = ";" THEN SIDES = 30 390 IF A$ = "'" THEN SIDES = 32 400 IF A$ = "B" THEN SIDES = 50 410 IF A$ = "N" THEN SIDES = 100 420 GOTO 90 430 REM ***** ROLL DICE 440 DIEROLL = 0 450 FOR I = 1 TO R 460 DIEROLL = DIEROLL+RND(SIDES) 470 NEXT I 480 PRINT R;"D";SIDES;"=";DIEROLL 490 RETURN 500 REM ***** MENU 510 PRINT 520 PRINT "1...0 - SPECIFY # OF ROLLS" 530 PRINT "A - SET TO D2 S - SET TO D3" 540 PRINT "D - SET TO D4 F - SET TO D6" 550 PRINT "G - SET TO D7 H - SET TO D8" 560 PRINT "J - SET TO D10 K - SET TO D12" 570 PRINT "L - SET TO D20 ; - SET TO D30" 580 PRINT "' - SET TO D32 B - SET TO D50" 590 PRINT "N - SET TO D100" 600 PRINT 610 PRINT"C - # OF DICE V - # OF SIDES" 620 PRINT"Z - CURRENT DIE X - ROLL DIE" 630 PRINT"W - EXPLODING E - SINGLETS" 640 PRINT "R - ROLL FUDGE DICE" 650 REM PRINT 660 PRINT"Q - QUIT M - MENU" 670 PRINT 680 RETURN 690 REM ***** EXPLODING DICE 700 DIEROLL = 0 710 COUNTR = R-1 720 FOR I = 1 TO COUNTR 730 DIEROLL = DIEROLL+RND(SIDES) 740 NEXT I 750 ROLLQ = RND(SIDES) 760 IF ROLLQ = SIDES THEN PRINT "EXPLODING" : DIEROLL = DIEROLL+ROLLQ 770 IF NOT (ROLLQ = SIDES) THEN DIEROLL = DIEROLL+ROLLQ 780 IF NOT (ROLLQ = SIDES) THEN GOTO 800 790 GOTO 750 800 PRINT "EXPLODING DIE ";R;"D";SIDES;"=";DIEROLL 810 RETURN 820 REM ***** SINGLET ROLLS 830 PRINT "SINGLETS FOR ";R;"D";SIDES ":" 840 FOR I = 1 TO R 850 PRINT "DICE ";I;"=";RND(SIDES) 860 NEXT I 870 RETURN 880 REM ***** FUDGE DICE 890 INPUT "# OF FUDGE DICE"; FUDGE 900 PRINT "ROLLING ";FUDGE;" FUDGE DICE." 910 FOR I = 1 TO FUDGE 920 DIEFUD = RND(6) 930 IF DIEFUD = 1 OR DIEFUD = 2 THEN PRINT "+" 940 IF DIEFUD = 3 OR DIEFUD = 4 THEN PRINT "[]" 950 IF DIEFUD = 5 OR DIEFUD = 6 THEN PRINT "-" 960 NEXT I 970 PRINT 980 PRINT "END OF FUDGE ROLL." 990 RETURN