Compute the evolution of a random square garden

This commit is contained in:
Dimitri Lozeve 2020-02-19 18:41:20 +01:00
parent 8b366f9457
commit 3bd21fd2db

View file

@ -53,7 +53,16 @@ function loadcosts()
costs = convert(Matrix, df[:, 2:end])
@debug "cost matrix of size $(size(costs))"
# ensure the matrix is symmetric: keep the max of itself and its transpose
costs = max.(costs, permutedims(costs))
costs = Float64.(max.(costs, permutedims(costs)))
end
function randomgridevolution(costs::Array{Float64, 2}, gardensize::Int = 50, steps::Int = 10000)
m = size(costs, 1)
grid = rand(1:m, gardensize, gardensize)
for i = 1:steps
update!(grid, costs, 10.0)
end
grid
end
end # module