Created
April 17, 2019 18:45
-
-
Save hatzka-nezumi/e50325ce0e5299745fa7d831f7c73c85 to your computer and use it in GitHub Desktop.
Glover & Glover notoriety simulation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'average' | |
simcount = 5000 | |
sims = [] | |
simcount.times do | |
puts "Starting simulation..." | |
stage = :none | |
ticks = 0 | |
while true do | |
ticks += 1 | |
if stage == :none then | |
if rand < 0.3 then | |
puts "Warned after #{ticks} ticks" | |
stage = :warned | |
end | |
elsif stage == :warned then | |
if rand < 0.7 then | |
puts "Fired after #{ticks} ticks" | |
break | |
end | |
end | |
end | |
sims.push ticks | |
end | |
puts "Ran #{simcount} simulations, mean #{sims.mean}, median #{sims.median}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment