CLS REM Program by Christopher Scott Lowell 'printout slightly edited by WB REM This is the first BASIC program for Applied Probabilities. REM This BASIC program will compute the chances of winning at craps REM or losing on the first toss 'nice introduction - both in file and in the program PRINT "This will compute the theoretical chance of " PRINT "winning, and loosing on the first toss in craps based "; "" PRINT "upon the counting method, and compare it with five trials of" PRINT "10000 tosses to check the validity of the model." PRINT '******************** counting sample points ********** a = 1 b = 1 c = 0 d = 0 e = 0 DO WHILE a < 7 b = 1 DO WHILE b < 7 c = a + b IF c = 7 THEN d = d + 1 ELSEIF c = 11 THEN d = d + 1 ELSEIF c = 2 THEN e = e + 1 END IF b = b + 1 LOOP a = a + 1 LOOP f = (INT((d / 36) * 1000)) / 1000 PRINT "The theoretical probrability of winning is "; f g = (INT((e / 36) * 1000)) / 1000 PRINT "The theoretical probrability of losing is "; g PRINT STRING$(80, "_"); '**************** simulation ************************ PRINT "Simulation #", "Pr that Win", "Pr that Loose" REM now we will test this by rolling 10000 times for five trials h = 0 i = 0 j = 0 k = 0 l = 0 m = 0 z = 0 DO WHILE z < 5 RANDOMIZE TIMER DO WHILE h < 10000 i = INT(RND(1) * 6) + 1 j = INT(RND(1) * 6) + 1 k = i + j IF k = 7 THEN l = l + 1 ELSEIF k = 11 THEN l = l + 1 ELSEIF k = 2 THEN m = m + 1 END IF h = h + 1 LOOP n = (l / 10000) o = (m / 10000) h = 0 l = 0 m = 0 z = z + 1 PRINT z, n, o IF z = 1 THEN a1 = n b1 = o ELSEIF z = 2 THEN a2 = n b2 = o ELSEIF z = 3 THEN a3 = n b3 = o ELSEIF z = 4 THEN a4 = n b4 = o ELSEIF z = 5 THEN a5 = n b5 = o END IF LOOP