From 3bd21fd2db425ad5d4661d3d4c0ad3f7bf750a55 Mon Sep 17 00:00:00 2001 From: Dimitri Lozeve Date: Wed, 19 Feb 2020 18:41:20 +0100 Subject: [PATCH] Compute the evolution of a random square garden --- src/GardenOptim.jl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/GardenOptim.jl b/src/GardenOptim.jl index c1d4f1f..74cdb0d 100644 --- a/src/GardenOptim.jl +++ b/src/GardenOptim.jl @@ -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