8-Bit Software Online Conversion

Craps Calculator - Listing

10REM" SCRAPS - Simulation of Craps 20REM J.Davis - '96. 30MODE7 40PRINT" * S C R A P S *" 50PRINT'" 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" 60PRINT" it might be 49.2929292%. Cle arly a computer simulation was call ed for to test this. It seems to be ab out right," 70PRINT" but the simulation has to ru n for several hours to settle down near this figure. Here it's set to run for just a"; 80PRINT" few minutes, with initial co nditions of: stake=£1000: constant be t=£10. You can change these. It runs ti ll your money disappears - you just watch." 90PRINT" 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 a t first - statistics will catch up wit h you eventually." 100PRINT'CHR$(145);STRING$(39,"£"); 110PRINTSPC(27);"PRESS SPACE"; 120G=GET 130M%=1000:BET%=10 140MM%=1000:BB%=10 150GT%=0:GW%=0:GL%=0 160T%=0:W%=0:L%=0:PC=0 170PROCheader 180PRINTCHR$(145);STRING$(39,",") 190PROCgtotal 200T%=0:W%=0:L%=0:PC%=0 210PRINTTAB(0,6);" Do you wish to ch ange these Initial Condition s (Y/N)?"; 220G$=GET$ 230IF G$="R" GT%=0:GW%=0:GL%=0:GOTO190 240IFG$<>"Y" THEN300 250INPUT''" Stake? "G:IF G<1 PRINTTA B(3);M% ELSE M%=G 260INPUTTAB(0,11);" Bet? "G 270IF G<1 PRINTTAB(3);BET%;:FORD=1TO80 0:NEXT ELSE BET%=G 280IF BET%>M% VDU7:PRINTTAB(2,13);" Yo u don't have that much money.";TAB(2)" P ress any key.";:GT=GET:M%=MM%:BET%=BB%:G OTO170 290MM%=M%:BB%=BET% 300VDU23,1,0;0;0;0; 310PROCheader 320PROCscreen 330TIME=0 340Z$=INKEY$(0):IFZ$="A" M%=MM%:VDU23, 1,1;0;0;0;:GOTO170 350T%=T%+1 360A%=RND(6)+RND(6) 370IF A%=7 OR A%=11 PROCwin:GOTO340 380IF A%=2 OR A%=3 OR A%=12 PROClose:G OTO430 390B%=RND(6)+RND(6) 400IF B%=A% PROCwin:GOTO340 410IF B%=7 PROClose:GOTO430 420GOTO390 430IF M%>=BET% THEN340 440VDU7:PRINTTAB(0,19);" Congratulat ions! You have become destitute i n ";(TIME DIV60)/100;" minutes."; 450VDU23,1,1;0;0;0; 460PRINTTAB(0,22);SPC(35) 470PRINTTAB(0,22);" AGAIN(Y/N)?"; 480G$=GET$ 490IF G$="Y" M%=MM%:GOTO170 500IFG$<>"N" THEN480 510PRINT'CHR$(148);STRING$(39,",");:EN D 520" ** 530DEFPROCwin 540W%=W%+1:M%=M%+BET%:PC=100*W%/T% 550PRINTTAB(3,5);T%;TAB(3,8);W%;TAB(5, 14);".0000000";TAB(3,14);PC;TAB(4,17);M% ;" " 560ENDPROC 570" ** 580DEFPROClose 590L%=L%+1:M%=M%-BET%:PC=100*W%/T% 600PRINTTAB(3,5);T%;TAB(3,11);L%;TAB(5 ,14);".0000000";TAB(3,14);PC;TAB(4,17);M %;" " 610ENDPROC 620" ** 630DEFPROCscreen 640PRINTTAB(0,5);" ";TAB(15,5);"Numb er of Games." 650PRINTTAB(0,8);" ";TAB(15,8);"Game s Won." 660PRINTTAB(0,11);" ";TAB(15,11);"Ga mes Lost." 670PRINTTAB(0,13);" 49.2929292 Theo retical Value." 680PRINTTAB(0,14);" ";TAB(15,14);"Pe rcent of Games Won." 690PRINTTAB(0,17);" £";TAB(15,17);"M oney Left." 700PRINTTAB(0,21)CHR$(148);STRING$(39, ",") 710PRINTTAB(2,22)" Press 'A' to start again." 720ENDPROC 730" ** 740DEFPROCheader 750CLS 760PRINTTAB(0,0);" * S C R A P S *" 770PRINTTAB(2,2);" Initial Conditions: " 780PRINTTAB(2,3);" Stake= £";M%;TAB(18 ,3);" Constant Bet= £";BET% 790ENDPROC 800" ** 810DEFPROCgtotal 820GT%=GT%+T%:GW%=GW%+W%:GL%=GL%+L% 830IF GT%>0 GPC=100*GW%/GT% ELSE GPC=0 840PRINTTAB(0,15);CHR$(148);STRING$(39 ,"£") 850PRINTTAB(0,16);" Grand Totals: ( R to reset)" 860FORN%=18TO24 STEP2:PRINTTAB(0,N%);S PC(14);:NEXT 870PRINTTAB(0,18);" ";GT%;TAB(15,18) ;"Number of Games." 880PRINTTAB(0,20);" ";GW%;TAB(15,20) ;"Games Won." 890PRINTTAB(0,22);" ";GL%;TAB(15,22) ;"Games Lost." 900PRINTTAB(0,23);" 49.2929292 Theo retical Value." 910PRINTTAB(0,24);" ";GPC;TAB(15,24) ;"Percent of Games Won."; 920ENDPROC 930" ** 940REM With initial stake of £100000 a nd bet of £10 (=10000 and 1), ran for 17 hours 11 minutes till money ran out. 950REM Results: Games: 790,442 Won: 39 0,221 Lost: 400,221 Percent won: 49.3674 425 (vs.theoretical 49.2929292).