1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
colorback (black)
cls
var preva : int := 0
var prevr : int := 0
const f1 : int := 5
const f2 : int := 100
const ofs : int := 300
const bn : int :=50
const ts : int := 600
const trs : int := 100
const hscl:int :=3
const hred:int :=5
for n : 1 .. ts
var buckets : array 1 .. bn of int
for i : 1 .. bn
buckets (i) := 0
end for
var ad : real := 0
var ratio : real := 0
for t : 1 .. trs %100 trials
var mcount : int := 1
var ncount : int := 1
for i : 1 .. n %play n number of games in trial
var m, nn : int
m := Rand.Int (1, 3)
nn := Rand.Int (1, 3)
if m = 1 and nn = 2 then
ncount := ncount + 1
elsif m = 2 and nn = 3 then
ncount := ncount + 1
elsif m = 3 and nn = 1 then
ncount := ncount + 1
elsif nn = 1 and m = 2 then %backwards
mcount := mcount + 1
elsif nn = 2 and m = 3 then
mcount := mcount + 1
elsif nn = 3 and m = 1 then
mcount := mcount + 1
end if
end for
drawdot (n, f1 * abs (ncount - mcount), white)
for k : 1 .. bn
if (abs (ncount - mcount) < k * ((ts/hred) / bn) and (abs (ncount - mcount) > (k - 1) * ((ts/hred) / bn))) then
buckets (k) := buckets (k) + hscl
end if
end for
ad := ad + (abs (ncount - mcount) / 100)
ratio := mcount / ncount
end for
drawline (n, round (f2 * ratio) + ofs, n - 1, prevr, brightred)
drawline (n, f1 * round (ad), n - 1, preva, yellow)
preva := round (f1 * ad)
prevr := round (f2 * ratio) + ofs
drawfillbox (0, 500, 200, 700, blue)
for i : 1 .. bn
drawfillbox (0, 500, round ((i) * (200 / bn)), 500 + buckets (i), white)
end for
drawline(round (ad*200/(ts/hred)),500,round (ad*200/(ts/hred)),700,yellow)
View.Update ()
end for
|