I would like to implement certain rules into relationship between my turtles and my patches. My Patches variables are:
- n_min - if there is enough turtles, change pcolor to pink, change yellow turtles on patch to orange
- n_max - if there is too many turtles, set pcolor to brown, let all turtles to avoid this patch
My turtles states are: yellow (move) -> orange (stay) -> red (infest) Patches states are: green (n_min< then number of orange turtles on one patch) pink (number of orange turtles is > n_min and < n_max) brown (no turtles)
My problem is how can I avoid to have more then n_max turtles on one patch if they are all moving at the same time and thus are targeted to same patch? How can I include the condition that "if you see that there are some turtles of color orange/red, just keep moving to find another patch? " Also, if my patch is already pink, and n_min != n_max to ask turtles to directly change its color to red?
Thank you a lot !
my not working example:
globals [
available-patch
]
patches-own [
nmax ; maximum nuber of turtles per patch, and change color
nmin ; minimum number of turtles to change patch color
n.yellow ; how many turtles are on the patch with yellow
n.orange ; how many orange (staying) turtles are on 1 patch?
]
to setup
clear-all
reset-ticks
setup-patches
setup-turtles
end
to setup-patches
ask n-of n_patches patches [
set pcolor green
set nmin n_min ; how many orange turtles can be there to set the patch to pink?
set nmax n_max ; max number of orange beetles to turn the patch to brown
]
end
to setup-turtles
crt n_turtles [
set color yellow
]
end
to go
tick
ask turtles with [color = yellow ] [ ; move only yellow turtles
move-turtles
]
ask patches [ ; if n.orange = nmin, turn all turtles to red and turn patch to pink
set n.orange count turtles-here with [color = orange]
]
end
to move-turtles
; if color = yellow ;and n.yellow < nmin
;ifelse count other turtles-on
; move-to one-of patches with [pcolor = green and n.orange <= nmin]
; if [n.orange <= nmin] of patch-here [
; set color orange ; not to move anymore. However, the n.orange should be always less then nmin !!
; ]
set available-patch patches with [pcolor = green and count turtles-here with [color = orange] < 2] ; agentset
ifelse (count other turtles-on available-patch <= nmin) ; how to change the code for nmin here?
[ move-to one-of available-patch
set color orange
ask patch-here [
set n.orange count turtles-here with [color = orange]
]
]
[ fd 2 ]
end
Result:
one turtle on the green patch has changed its color to orange, but I wanted 2 turtles (nmin) to find green patch and become orange. Also, the yellow turtles move next time steps just by [fd 2], the "ifelse" condition is not re-run each time step.
