I have this code were one agent searches for forests to destroy them, while the other agent looks for grass that is empty meaning that there is no other agents. The code works, however every tick it gets slower. I do believe that the if´s are taxing the processor, however it should be equally taxing throught the run. I have other process in the code, but i have concluded that this one is the thats hitting hard.
Landowner Agent
Objetivo = Target patch to transform
Forest# = Property of the patches, its just what canopy it has
The world (Map) is fairly big. Still i dont get why it gets slower over time
ask landowner[ifelse patch-here = objetivo
[ifelse any? neighbors with [Tipo-Cobertura = "Forest1"] [set objetivo min-one-of patches with [Tipo-Cobertura = "Forest1"][distance myself]]
[ifelse any? neighbors with [Tipo-Cobertura = "Forest2"] [set objetivo min-one-of patches with [Tipo-Cobertura = "Forest2"][distance myself]]
[ifelse any? neighbors with [Tipo-Cobertura = "Forest3" ] [set objetivo min-one-of patches with [Tipo-Cobertura = "Forest3"][distance myself]]
[ifelse any? neighbors with [Tipo-Cobertura = "Forest4"][set objetivo min-one-of patches with [Tipo-Cobertura = "Forest4"][distance myself]]
[if any? neighbors with [Tipo-Cobertura = "Forest5"] [set objetivo min-one-of patches with [Tipo-Cobertura = "Forest5"][distance myself]]]]]]][face objetivo fd 1]]
ask expansionist [ifelse patch-here = objetivo
[if any? neighbors with [Tipo-Cobertura = "Grass" and (not any? neighbors with [es-bosque = 1])][set objetivo min-one-of patches with [Tipo-Cobertura = "Grass" and not any? neighbors with [es-bosque = 1] and empty = 1][distance myself]]] [face objetivo fd 1]]
Does the land cover change over time in this model? From what I see, grass is quite demanding because the distance to every single grass patch is measured, whereas forests are subdivided into categories so the distance is only measured to about 1/5 patches with forests. If the system gets progressively more grass, it should slow down. Anyway, your usage of min-one-of
in a system with a lot of patches when you have already established that one of the neighboring patches fits the criteria is not great. You don't need to sample any other patches than the 8 neighboring ones.
Try replacing
set objetivo min-one-of patches with [Tipo-Cobertura = "Forest1"][distance myself]
with
set objetivo one-of neighbors with [Tipo-Cobertura = "Forest1"]