Compute the evolution of a random square garden
This commit is contained in:
parent
8b366f9457
commit
3bd21fd2db
1 changed files with 10 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue