10 REM"SCRAPS- Simulation of Craps 20 REM J.Davis - '96. 30 MODE7 40 PRINT" * S C R A P S *" 50 PRINT'" The CRAPS program in 8BS-46 by Jon Ripley made me wonder what the odds were on winning. Scratching about with a calculator and some paper suggested" 60 PRINT"it might be 49.2929292%. Clearly a computer simulation was called for to test this. It seems to be about right," 70 PRINT"but the simulation has to run for several hours to settle down near this figure. Here it's set to run for just a"; 80 PRINT"few minutes, with initial conditions of: stake=`1000: constant bet=`10. You can change these. It runs till your money disappears - you just watch." 90 PRINT" With these conditions, you should lose your loot at an average rate of `141-41 per 1000 games. And don't be fooled if you start to win at first - statistics will catch up with you eventually." 100 PRINT'CHR$(145);STRING$(39,"`"); 110 PRINTSPC(27);"PRESS SPACE"; 120 G=GET 130 M%=1000:BET%=10 140 MM%=1000:BB%=10 150 GT%=0:GW%=0:GL%=0 160 T%=0:W%=0:L%=0:PC=0 170 PROCheader 180 PRINTCHR$(145);STRING$(39,",") 190 PROCgtotal 200 T%=0:W%=0:L%=0:PC%=0 210 PRINTTAB(0,6);" Do you wish to change these Initial Conditions (Y/N)?"; 220 G$=GET$ 230 IF G$="R" GT%=0:GW%=0:GL%=0:GOTO190 240 IFG$<>"Y" THEN300 250 INPUT''" Stake?"G:IF G<1 PRINTTAB(3);M% ELSE M%=G 260 INPUTTAB(0,11);" Bet?"G 270 IF G<1 PRINTTAB(3);BET%;:FORD=1TO800:NEXT ELSE BET%=G 280 IF BET%>M% VDU7:PRINTTAB(2,13);"You don't have that much money.";TAB(2)"Press any key.";:GT=GET:M%=MM%:BET%=BB%:GOTO170 290 MM%=M%:BB%=BET% 300 VDU23,1,0;0;0;0; 310 PROCheader 320 PROCscreen 330 TIME=0 340 Z$=INKEY$(0):IFZ$="A" M%=MM%:VDU23,1,1;0;0;0;:GOTO170 350 T%=T%+1 360 A%=RND(6)+RND(6) 370 IF A%=7 OR A%=11 PROCwin:GOTO340 380 IF A%=2 OR A%=3 OR A%=12 PROClose:GOTO430 390 B%=RND(6)+RND(6) 400 IF B%=A% PROCwin:GOTO340 410 IF B%=7 PROClose:GOTO430 420 GOTO390 430 IF M%>=BET% THEN340 440 VDU7:PRINTTAB(0,19);" Congratulations! You have become destitute in ";(TIME DIV60)/100;" minutes."; 450 VDU23,1,1;0;0;0; 460 PRINTTAB(0,22);SPC(35) 470 PRINTTAB(0,22);" AGAIN(Y/N)?"; 480 G$=GET$ 490 IF G$="Y" M%=MM%:GOTO170 500 IFG$<>"N" THEN480 510 PRINT'CHR$(148);STRING$(39,",");:END 520 "** 530 DEFPROCwin 540 W%=W%+1:M%=M%+BET%:PC=100*W%/T% 550 PRINTTAB(3,5);T%;TAB(3,8);W%;TAB(5,14);".0000000";TAB(3,14);PC;TAB(4,17);M%;" " 560 ENDPROC 570 "** 580 DEFPROClose 590 L%=L%+1:M%=M%-BET%:PC=100*W%/T% 600 PRINTTAB(3,5);T%;TAB(3,11);L%;TAB(5,14);".0000000";TAB(3,14);PC;TAB(4,17);M%;" " 610 ENDPROC 620 "** 630 DEFPROCscreen 640 PRINTTAB(0,5);"";TAB(15,5);"Number of Games." 650 PRINTTAB(0,8);"";TAB(15,8);"Games Won." 660 PRINTTAB(0,11);"";TAB(15,11);"Games Lost." 670 PRINTTAB(0,13);" 49.2929292 Theoretical Value." 680 PRINTTAB(0,14);"";TAB(15,14);"Percent of Games Won." 690 PRINTTAB(0,17);"`";TAB(15,17);"Money Left." 700 PRINTTAB(0,21)CHR$(148);STRING$(39,",") 710 PRINTTAB(2,22)"Press 'A' to start again." 720 ENDPROC 730 "** 740 DEFPROCheader 750 CLS 760 PRINTTAB(0,0);" * S C R A P S *" 770 PRINTTAB(2,2);"Initial Conditions:" 780 PRINTTAB(2,3);"Stake=`";M%;TAB(18,3);"Constant Bet=`";BET% 790 ENDPROC 800 "** 810 DEFPROCgtotal 820 GT%=GT%+T%:GW%=GW%+W%:GL%=GL%+L% 830 IF GT%>0 GPC=100*GW%/GT% ELSE GPC=0 840 PRINTTAB(0,15);CHR$(148);STRING$(39,"`") 850 PRINTTAB(0,16);" Grand Totals: (R to reset)" 860 FORN%=18TO24 STEP2:PRINTTAB(0,N%);SPC(14);:NEXT 870 PRINTTAB(0,18);"";GT%;TAB(15,18);"Number of Games." 880 PRINTTAB(0,20);"";GW%;TAB(15,20);"Games Won." 890 PRINTTAB(0,22);"";GL%;TAB(15,22);"Games Lost." 900 PRINTTAB(0,23);" 49.2929292 Theoretical Value." 910 PRINTTAB(0,24);"";GPC;TAB(15,24);"Percent of Games Won."; 920 ENDPROC 930 "** 940 REM With initial stake of `100000 and bet of `10 (=10000 and 1), ran for 17 hours 11 minutes till money ran out. 950 REM Results: Games: 790,442 Won: 390,221 Lost: 400,221 Percent won: 49.3674425 (vs.theoretical 49.2929292).