Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,53 @@
const cyl = zeros(Bool, 6)
function load()
while cyl[1]
cyl .= circshift(cyl, 1)
end
cyl[1] = true
cyl .= circshift(cyl, 1)
end
spin() = (cyl .= circshift(cyl, rand(1:6)))
fire() = (shot = cyl[1]; cyl .= circshift(cyl, 1); shot)
function LSLSFSF()
cyl .= 0
load(); spin(); load(); spin()
fire() && return true
spin(); return fire()
end
function LSLSFF()
cyl .= 0
load(); spin(); load(); spin()
fire() && return true
return fire()
end
function LLSFSF()
cyl .= 0
load(); load(); spin()
fire() && return true
spin(); return fire()
end
function LLSFF()
cyl .= 0
load(); load(); spin()
fire() && return true
return fire()
end
function testmethods(N = 10000000)
for (name, method) in [("load, spin, load, spin, fire, spin, fire", LSLSFSF),
("load, spin, load, spin, fire, fire", LSLSFF),
("load, load, spin, fire, spin, fire", LLSFSF),
("load, load, spin, fire, fire", LLSFF)]
percentage = 100 * sum([method() for _ in 1:N]) / N
println("Method $name produces $percentage per cent deaths.")
end
end
testmethods()