Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,34 @@
|
|||
Declare random1 lib "advapi32.SystemFunction036" {long lpbuffer, long length}
|
||||
Flush
|
||||
Prob(4, 9, 6, 6, 55555)
|
||||
Prob(10, 5, 7, 6, 55555)
|
||||
Sub Prob(face1 as long=4 ,dice1=9, face2 as long=6,dice2=6, games=1000)
|
||||
if face1<1 or face1>256 or face2<1 or face2>256 then Error "Faces out of limits"
|
||||
profiler
|
||||
local m=@PlayAll(dice1,dice2, games), tt=timecount
|
||||
print "Time to fill the buffer with random bytes ";str$(tt, "#0.00 ms")
|
||||
local s1=dice1-1, s2=dice2-1, k, l, f1=face1/256, f2=face2/256, i, n1=0&, n2=0&
|
||||
print "Buffer size ";str$(len(m)/1024,"#0.#");" Kbyte": Refresh
|
||||
profiler
|
||||
for i=0 to games-1
|
||||
long n1=dice1:for j=0to s1{n1+=eval(m, i!n1!j)*f1}
|
||||
long n2=dice2:for j=0to s2{n2+=eval(m, i!n2!j)*f2}
|
||||
if n1>n2 then k++ else if n1<n2 then l++
|
||||
next
|
||||
print "Games Total "; games
|
||||
print "Player 1 wins ";k; " probability of winning:" ;str$(k/games, "#0.00 %")
|
||||
print "Player 2 wins ";l; " probability of winning:" ;str$(l/games, "#0.00 %")
|
||||
print "Number of ties ";games-k-l
|
||||
print "Execution time ";str$(timecount/1000, "#0.0 s")
|
||||
End Sub
|
||||
Function PlayAll(dice1, dice2, games as long)
|
||||
if games<1 then error "games<1"
|
||||
local onegame
|
||||
structure onegame {
|
||||
n1 as byte * dice1
|
||||
n2 as byte * dice2
|
||||
}
|
||||
buffer Alfa as onegame*games
|
||||
call void random1(alfa(0), len(alfa))
|
||||
= Alfa
|
||||
End Function
|
||||
Loading…
Add table
Add a link
Reference in a new issue