BadbeatBurley
Programmer
I have written a small visual basic program that simulates a dice roll and tallies the results.
I seed the random number generator with the milliseconds value of time to start the program.
The results always have the number six come up less than the 16.66 percent than it should. Can someone explain why?
1000 T = 100000
1012 Dim Arrayz (2,7)
1200 ' Load array
1600 FOR N = 1 TO T
1612 Y = ((RND(1)*6) +1)
1620 Z = int(Y)
2000 Arrayz(1,Z) = Arrayz (1,Z) + 1
2010 next N
2040 ' load array for sorting
2050 For X = 1 to 6
2110 Arrayz(2,X) = X
2200 next X
2202 ' sort array
2250 C = 0
2300 For X = 1 to 5
2305 If Arrayz(1,X) > Arrayz(1,X+1) then
2310 Arrayz(1,7) = Arrayz(1,X)
2315 Arrayz(1,X) = Arrayz(1,X+1)
2320 Arrayz(1,X+1) = Arrayz(1,7)
2330 Arrayz(2,7) = Arrayz(2,X)
2333 Arrayz(2,X) = Arrayz(2,X+1)
2337 Arrayz(2,X+1) = Arrayz(2,7)
2339 C = 1
2340 else
2344 end if
2350 Next X
2360 IF C = 1 then goto 2250
2499 'unload and print
2500 For X = 1 to 6
2560 P = (Arrayz(1,X)/T)*100
2580 Pcnt6$ = using("##.####", P)
2590 Print "%",Pcnt6$ ," ", Arrayz(2,X)
2600 Next X
3002 end
I seed the random number generator with the milliseconds value of time to start the program.
The results always have the number six come up less than the 16.66 percent than it should. Can someone explain why?
1000 T = 100000
1012 Dim Arrayz (2,7)
1200 ' Load array
1600 FOR N = 1 TO T
1612 Y = ((RND(1)*6) +1)
1620 Z = int(Y)
2000 Arrayz(1,Z) = Arrayz (1,Z) + 1
2010 next N
2040 ' load array for sorting
2050 For X = 1 to 6
2110 Arrayz(2,X) = X
2200 next X
2202 ' sort array
2250 C = 0
2300 For X = 1 to 5
2305 If Arrayz(1,X) > Arrayz(1,X+1) then
2310 Arrayz(1,7) = Arrayz(1,X)
2315 Arrayz(1,X) = Arrayz(1,X+1)
2320 Arrayz(1,X+1) = Arrayz(1,7)
2330 Arrayz(2,7) = Arrayz(2,X)
2333 Arrayz(2,X) = Arrayz(2,X+1)
2337 Arrayz(2,X+1) = Arrayz(2,7)
2339 C = 1
2340 else
2344 end if
2350 Next X
2360 IF C = 1 then goto 2250
2499 'unload and print
2500 For X = 1 to 6
2560 P = (Arrayz(1,X)/T)*100
2580 Pcnt6$ = using("##.####", P)
2590 Print "%",Pcnt6$ ," ", Arrayz(2,X)
2600 Next X
3002 end