Created
November 8, 2015 21:36
-
-
Save GordStephen/47c5f005fc0a016c1ba6 to your computer and use it in GitHub Desktop.
This file contains 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
# Simulate Gen III Feebas fishing | |
S = 100000 # Simulations per cast count choice | |
N = 446 # Number of accessible water tiles on Route 119 | |
K = 6 # Number of Feebas tiles on the map | |
p = .5 # Probability of encountering a Feebas on a Feebas tile | |
M = 6 # Maximum number of casts per tile to simulate | |
find_feebas(is_feebas_tile) = is_feebas_tile ? rand() < p : false | |
function simulate_fishingtrip(m::Int) | |
tiles = falses(N) | |
feebas_tiles = shuffle(collect(1:N))[1:K] | |
tiles[feebas_tiles] = true | |
casts = missed = 0 | |
while true | |
for i in eachindex(tiles) | |
for j in 1:m | |
casts += 1 | |
find_feebas(tiles[i]) && return casts, missed | |
end #for | |
tiles[i] && (missed += 1) | |
end #for | |
end #while | |
end #simulate_fishingtrip | |
results = zeros(S, M) | |
misses = zeros(S, M) | |
for s in 1:S, m in 1:M | |
results[s, m], misses[s, m] = simulate_fishingtrip(m) | |
end #for | |
cast_average = mean(results,1)' | |
miss_average = mean(misses,1)' | |
println("Casts per tile | Average total misses | Average total casts") | |
println("---------------|----------------------|--------------------") | |
map((i, m, u) -> @printf("%7d | %11.2f | %13.2f \n", i, m, u), 1:M, miss_average, cast_average) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment