Efficiency of the model: Turn by turn irrigate with who numbers - netlogo

I have written NetLogo code to make turtles change value turn by turn. Turtles are the farmers placed along a water stream. They will have differences in spatial water availability based on their who numbers and they will withdraw water as per their turn based on who number. Codes are doing fine. Every tick is taking more than usual time. I am seeing that the complete model will take even more time to run. Can these codes be changed to make the model efficiently run as per the set pattern given in the attached picture?
Thanks for the help
Codes are given below
Breed [farmers farmer]
Farmers-own [water irrigation-turn]
to setup
clear-all
create-farmers 30 [ set irrigation-turn [0]
ask farmer 0 [ setxy min-pxcor + 1 0]
ask farmer 1 [ setxy min-pxcor + 1 2]
ask farmer 20 [ setxy min-pxcor + 1 4]
ask farmer 2 [ setxy min-pxcor + 3 0]
ask farmer 3 [ setxy min-pxcor + 3 2]
ask farmer 21 [ setxy min-pxcor + 3 4]
ask farmer 4 [ setxy min-pxcor + 5 0]
ask farmer 5 [ setxy min-pxcor + 5 2]
ask farmer 22 [ setxy min-pxcor + 5 4]
ask farmer 6 [ setxy min-pxcor + 7 0]
ask farmer 7 [ setxy min-pxcor + 7 2]
ask farmer 23 [ setxy min-pxcor + 7 4]
ask farmer 8 [ setxy min-pxcor + 9 0]
ask farmer 9 [ setxy min-pxcor + 9 2]
ask farmer 24 [ setxy min-pxcor + 9 4]
ask farmer 10 [ setxy min-pxcor + 11 0]
ask farmer 11 [ setxy min-pxcor + 11 2]
ask farmer 25 [ setxy min-pxcor + 11 4]
ask farmer 12 [ setxy min-pxcor + 13 0]
ask farmer 13 [ setxy min-pxcor + 13 2]
ask farmer 26 [ setxy min-pxcor + 13 4]
ask farmer 14 [ setxy min-pxcor + 15 0]
ask farmer 15 [ setxy min-pxcor + 15 2]
ask farmer 27 [ setxy min-pxcor + 15 4]
ask farmer 16 [ setxy min-pxcor + 17 0]
ask farmer 17 [ setxy min-pxcor + 17 2]
ask farmer 28 [ setxy min-pxcor + 17 4]
ask farmer 18 [ setxy min-pxcor + 19 0]
ask farmer 19 [ setxy min-pxcor + 19 2]
ask farmer 29 [ setxy min-pxcor + 19 4]
ask farmers [ set label who
set size 2]
]
reset-ticks
end
to go
define-irrigation-turn
irrigate
tick
end
to define-irrigation-turn ; 11 turtle ; 24 hours irrigation policy
ask farmers [set irrigation-turn [0]
ask farmer 0 [
repeat 235 [
set irrigation-turn lput 1 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
]]
ask farmer 1 [
repeat 235 [
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 1 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
]]
ask farmer 2 [
repeat 235 [
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 1 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
]]
ask farmer 3 [
repeat 235 [
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 1 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
]]
ask farmer 4 [
repeat 235 [
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 1 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
]]
ask farmer 5 [
repeat 235 [
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 1 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
]]
ask farmer 6 [
repeat 235 [
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 1 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
]]
ask farmer 7 [
repeat 235 [
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 1 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
]]
ask farmer 8 [
repeat 235 [
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 1 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
]]
ask farmer 9 [
repeat 235 [
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 1 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
]]
ask farmer 10 [
repeat 235 [
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 1 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
]]
ask farmer 11 [
repeat 235 [
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 1 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
]]
ask farmer 12 [
repeat 235 [
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 1 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
]
; Turtles 13-16 will follow the same pattern
]
ask farmer 17 [
repeat 235 [
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 1 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
]]
ask farmer 18 [
repeat 235 [
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 1 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
]]
ask farmer 19 [
repeat 235 [
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 1 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
]]
ask farmer 20 [
repeat 235 [
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 1 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
]]
ask farmer 21 [
repeat 235 [
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 1 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
set irrigation-turn lput 0 irrigation-turn
]]
; farmers from 26-29 will follow the same pattern as of 20 t0 21
]
end
to irrigate
foreach [0 1 2 3 4 5 6 7 8 9 10 12 14 16 18 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30]
[ ?1 ->
ask farmers with [who = ?1] [
if (item ticks irrigation-turn) = 1
[ set color red
set shape "person"
]]]
end

You have a fundamental misunderstanding about how time works in these models. The command tick instructs the model to advance the clock. That is embedded in a go procedure and that go procedure (presumably) runs each tick. What you need in the go procedure is what happens during ONE time step. Instead, at the moment, you are appending another five years of schedule.
If you need to have a schedule because you want each turtle to take a turn and then move on to the next turtle in the next tick, construct the schedule during the setup procedure, not the go procedure. You should probably also use the mod operator since it's a cycle, so you don't need five years of schedule, you can just have one cycle stored. You also don't need to use lput to append each item individually, just provide the whole list at once.
Something like this (note I have abandoned the schedule entirely and just use mod to cycle):
breed [farmers farmer]
farmers-own [water irrigation-turn]
to setup
clear-all
create-farmers 30
[ set label who
set size 2
]
ask farmer 0 [ setxy min-pxcor + 1 0 set irrigation-turn 0]
ask farmer 1 [ setxy min-pxcor + 1 2 set irrigation-turn 1]
ask farmer 20 [ setxy min-pxcor + 1 4 set irrigation-turn 2]
; and similarly for remaining farmers
reset-ticks
end
to go
irrigate
tick
end
to irrigate
ask turtles with [irrigation-turn = (ticks mod count farmers)]
; do whatever it is they do when it's their turn
ask turtles with [irrigation-turn != (ticks mod count farmers)]
; do whatever it is they do when it's not their turn
end
Or if you want to keep a schedule (for example, because there are some weeks that don't fit a cycle), then construct one directly. For example, if you wanted week 3 of a 4 week cycle, you can simply do:
set irrigation-turn [ 0 0 1 0]
There are other techniques using reduce sentence n-values to do much longer lists, but I think your efficiency problem can be solved without them.

Your speed issue is because you are creating a long list using :
set irrigation-turn lput 1 irrigation-turn
You'll need to make sure the list isn't growing linear with respect to ticks

Related

Hatch not changing the Breed Netlogo

im trying to change the breed of my turtles at hatch but its just giving the mothers breed.
if more code is need please let me know. Thanks!
So, the edit is a more complete code and can be copy pasted. The idea is that if males (machos) find a females (hembra) then they should reproduce, and the new hatch needs to be either male or female. However this is not happenign, theres only females, i chagned the variables in such way that they reproduce alot, meaning that i should see at least one male spawn, but it doesnt.
turtles-own[energia fecundidad vejez]
breed[machos macho]
breed[hembras hembra]
patches-own[alimento]
to setup
resize-world 0 90 0 60
clear-all
ask patches with [
pxcor <= 30 and
pxcor >= min-pxcor and
pycor <= 60 and
pycor >= min-pycor ] [
set pcolor 65
set alimento random 100
]
set-default-shape turtles "cow"
create-machos 3
[ set size 3 ;; easier to see
set color gray
setxy random xcor random ycor
move-to one-of patches with [pcolor = 65]
set heading random 45 + 45
set energia random 500
set fecundidad 0
set vejez 0
]
set-default-shape turtles "cow"
create-hembras 3
[ set size 3 ;; easier to see
set color black
set xcor random 30
set ycor random 60
move-to one-of patches with [pcolor = 65]
set heading random 45 + 45
set energia random 500
set fecundidad 0
set vejez 0
]
reset-ticks
end
to go
ask machos [
if energia >= 60 [reproducirse]
set heading random 360
fd 1
set energia energia - 1
]
ask machos [set fecundidad fecundidad + 1]
ask machos [set vejez vejez + 1]
ask hembras [
if energia >= 50 [reproduccion_hembra]
set heading random 360
fd 1
set energia energia - 1
]
ask hembras [set fecundidad fecundidad + 1]
ask hembras [set vejez vejez + 1]
tick
end
to reproducirse
ask machos[if any? hembras with [fecundidad >= 6][ set heading towards one-of hembras with [fecundidad >= 6]]
]
end
to reproduccion_hembra
ask hembras [ if energia >= 50 [if any? machos in-radius 4 [ set energia energia - 60
hatch 2 [set breed one-of (list machos hembras) rt random-float 360 fd 15
set energia (100 + random 400)
set vejez 0]]]]
end

expected input to be a number but got the TRUE/FALSE true instead

I want to write an evacuation with leader code in net-logo but i have this error (AND expected input to be a TRUE/FALSE but got the number 0 instead.)the error came from function (follow_leader). my project is that i evacuate an environment and evacuate it with the nearest leader from the crowd . the code is not perfect that because iam knew to netlogo .
this is my code
globals[ goal-x goal-y n number leader
percent_of_leader wall
window
door largecircle]
patches-own [path?
obstacle
goal]
turtles-own [direction
fast?
fear?
leader?
is-leader?
follower
other-nearby]
to setup
clear-all
set-default-shape turtles "person"
;create-turtles 50 [ set color yellow ]
;ask turtles [fd random 13 ]
drwa-walls
ask n-of population patches with [ pcolor = black]
[sprout 1
[ set color white
set size 0.9
set shape "person"
set leader? false
;set follower self
if xcor < 9 and ycor > 9 [set heading 0]
if xcor >= 9 and ycor >= -10[set heading -90]
if xcor > -12 and ycor < -10 [set heading 90]
if xcor <= -8 and ycor > -10 and ycor < 0 [set heading 180]
]]
choose-leaders
end
to choose-leaders
ask turtle 6
[
set leader? true
set color yellow
set size 1
set shape "default"
set leader self
set xcor 3
set ycor 10
set heading 0
]
end
to go
move-for
ask turtle 6[move-to-exit1
fd 1 ]
ask turtles with [shape = "person"][
ifelse (xcor < 9 and ycor > 9 ) [follow_leader] [move-to-exit1]
if xcor >= 9 and ycor >= -10 [move-to-exit2]
if xcor > -12 and ycor < -10 [move-to-exit3]
if xcor < -12 and ycor < -10 [move-to-exit3]
if xcor <= -8 and ycor > -10 and ycor < 0 [move-to-exit4]
;avoid obstcao
; avoid_obstacles
;ifelse [pcolor] of patch-ahead 1 = blue
; [ lt random-float 360 ] ;; We see a blue patch in front of us. Turn a random amount.
;[ fd 1 ] ;; Otherwise, it is safe to move forward.
; ifelse not is-patch? patch-ahead 3 or [ pcolor ] of patch-ahead 3 =
;blue or not is-patch? patch-ahead 2 or [ pcolor ] of patch-ahead 2 =
;blue or not is-patch? patch-ahead 1 or [ pcolor ] of patch-ahead 1 =
;blue
;[lt random-float 360 ]
;[fd 1]
; while [patch-ahead 1 = nobody]
;[
;lt random-float 360
;]
;ifelse [pcolor] of patch-ahead 1 = blue
; [ lt random-float 360 ] ;; We see a blue patch in front of us. Turn a random amount.
;[ fd 1 ]
; ifelse not is-patch? patch-ahead 3 or [ pcolor ] of patch-ahead 3 =
;white or not is-patch? patch-ahead 2 or [ pcolor ] of patch-ahead 2 =
;white or not is-patch? patch-ahead 1 or [ pcolor ] of patch-ahead 1 =
;white
; [lt random-float 360 ]
; [fd 1]
;ifelse not is-patch? patch-ahead 3 or [ pcolor ] of patch-ahead 3 =
;green or not is-patch? patch-ahead 2 or [ pcolor ] of patch-ahead 2 =
;green or not is-patch? patch-ahead 1 or [ pcolor ] of patch-ahead 1 =
;green
;[lt random-float 360]
; [fd 1]
]
reset-ticks
tick
end
to rt-random
while [patch-ahead 3 = nobody]
[
rt random 360
]
end
to avoide
ask turtles [
if [pcolor] of patch-ahead 1 = green
[lt random 360 fd 1]
]
end
to avoid_obstacles ;; all obstacles set as green patches
let i 1
while [[pcolor] of patch-ahead i != blue ]
[set i (i + 1) ]
if ([pcolor] of patch-ahead i = blue)
[
ifelse [pcolor] of patch-at-heading-and-distance (heading - 20) i + 1 = blue
[
ifelse [pcolor] of patch-at-heading-and-distance (heading + 20) i + 1 = blue
[
ifelse random 1 = 0
[ rt 360 ]
[ lt 360]
]
[ rt 360 ]
]
[lt 360]
]
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;
to bounce
if [pcolor] of patch-at dx 8 = blue [
set heading (90)
]
if [pcolor] of patch-at 0 dy = blue [
set heading (-90)
]
end
;;;;;;;;;;;;;;;;;;;;;;;
to move-for
ask turtles with [shape = "person"][fd 1]
end
to drwa-walls
draw-exit1
draw-exit2
draw-exit3
draw-exit4
;rows x
ask patches with [pxcor <= 30 and pxcor >= 0 and pycor = -10]
[set pcolor blue]
ask patches with [pxcor >= -30 and pxcor <= 0 and pycor = 9]
[set pcolor blue]
;coilmn
;ask patches with [pycor <= 9 and pycor >= -10 and pxcor = 0]
;[set pcolor green]
;ask patches with [pycor <= 4 and pycor >= 0 and pxcor = 0]
;[set pcolor green]
;circle shape
ask patch -14 -9 [
set largecircle patches in-radius (2)
]
;set color of largecircle patches green
ask largecircle [
set pcolor green
]
ask patch 16 16 [
set largecircle patches in-radius (2)
]
;set color of largecircle patches green
ask largecircle [
set pcolor white
]
end
to draw-exit1
;exits at top of concourse area, where turtles will leave
set goal-x -1
set goal-y -30
ask patch goal-x goal-y [
sprout 1 [ set pcolor red
set shape "square"
]
]
end
to draw-exit2
set goal-x -1
set goal-y 30
ask patch goal-x goal-y [
sprout 1 [ set pcolor red
set shape "square"
]
]
end
to draw-exit3
set goal-x -30
set goal-y -6
ask patch goal-x goal-y [
sprout 1 [ set pcolor red
set shape "square"
]
]
end
to draw-exit4
set goal-x 30
set goal-y 4
ask patch goal-x goal-y [
sprout 1 [ set pcolor red
set shape "square"
]
]
end
;;;;;;;;;;;;;;;;;;;;;;exit goals;;
to move-to-exit1
facexy -1 30
end
to move-to-exit2
facexy 30 4
end
to move-to-exit3
facexy -1 -30
end
to move-to-exit4
facexy -30 -6
end
;;;;;;;;;;;;;;;;;;;;;;;;;;
;to follow-leader
;if not leader? ;; we only want to ask non-leaders
;[let nearby-leaders turtles with [leader? and distance myself < 3] ;; find nearby leaders
;if any? nearby-leaders ;; to avoid 'nobody'-error, check if there are any first
; [ set heading (towards min-one-of nearby-leaders [distance myself]) ]] ;; then face the one closest to myself
; end
;;;;;;;;;;;;;;;;;;;;;;;;;;
to follow_leader
let nearby-leaders turtles with [is-leader? and distance myself < 10] ;; nearby leaders
if any? nearby-leaders[
face min-one-of nearby-leaders [distance myself]
fd 0.5]
end
In the future, please only provide relevant code. For NetLogo, that is usually the procedure that throws the error (or doesn't work correctly etc) and whichever procedure calls it.
In your case, this is the procedure you mentioned:
to follow_leader
let nearby-leaders turtles with [is-leader? and distance myself < 10]
if any? nearby-leaders[
face min-one-of nearby-leaders [distance myself]
fd 0.5]
end
So the and that is throwing the error must be [is-leader? and distance myself < 10] (also, please state which line if you know it). My guess would be that you haven't initialised the variable is-leader? so it is 0 (the default value) instead of either true or false.
If this is the problem, wherever you creates turtles, initialise with set is-leader? false

turtles change color on particular patch color

this code contains a road setup and turtle creation , after that on the go procedure that makes turtles take the pink path , and am trying to make turtles change color with they get to a red colored patch , but for unknown reason this code is not working and the cars never change their color and stay blue as there creation color
i hope i get some help to do it
turtles-own [
speed
s?
]
to setup-road
clear-all
ask patches [
ifelse pycor < -8 and pycor > -17 [set pcolor black ]
[set pcolor gray - 3 ]
if pycor < -9 and pycor > -15 [ set pcolor gray ]
if pycor > -10 and pycor < -8 and pxcor > 20 and pxcor < 27
[set pcolor white ]
if pycor < -2 and pycor > -4 and pxcor < 20 and pxcor > -24
[set pcolor pink ]
if pycor < -3 and pycor > -10 and pxcor < -22 and pxcor > -24
[set pcolor green ]
if pxcor = 20 and pycor = -3
[set pcolor red
]
]
set-default-shape turtles "car"
create-turtles 2 [
set color blue
set size 2
set xcor random-xcor
set ycor -12
set heading 90
set speed 0.1 + random-float 0.9
set s? true
]
reset-ticks
end
to go
ask turtles [
let car-ahead one-of turtles-on patch-ahead 2
if car-ahead != nobody
[ fd speed]
let gate one-of patches in-radius 5 with [pcolor = green ]
let path one-of patches in-radius 5 with [pcolor = pink ]
if s?
[ ifelse gate != nobody
[ move-to gate
fd speed
ifelse path != nobody
[
move-to path
fd speed
if patch-ahead 1 != nobody and pcolor != pink
[set color green ]
]
[fd speed]]
[fd speed]
]
]
tick
end

avoiding patch that has turtle netlogo

Can anyone help me with this. I'am trying to simulate a situation wherein the turtle will randomly sit on a bench (red patch) and if the bench is occupied it will find another one.
1 turtle: 1 patch
breed [kids kid]
breed [adults adult]
breed [oldies old]
kids-own [step]
adults-own [step]
oldies-own [step]
to setup
__clear-all-and-reset-ticks
ask patches [setup-world]
set-default-shape turtles "person"
create-kids number-of-kids
create-adults number-of-adults
create-oldies number-of-oldies
ask kids[
set color green
set size 1
setxy -10 0
set heading random-float 90
rt 45 - random-float 90]
ask adults[
set color orange
set size 1
setxy -10 0
set heading random-float 45
rt 45 - random-float 90]
to setup-world
set pcolor white
if ( pxcor = 10 ) and ( pycor < 10 and pycor > -11 ) [ set pcolor brown ]
if ( pxcor = -10 ) and ( pycor < 10 and pycor > 1 ) [ set pcolor brown ]
if ( pxcor = -10 ) and ( pycor < -1 and pycor > -11 ) [ set pcolor brown ]
if ( pycor = 10 ) and ( pxcor < 11 and pxcor > -11 ) [ set pcolor brown ]
if ( pycor = -10 ) and ( pxcor < 10 and pxcor > -11 ) [ set pcolor brown ]
if ( pxcor = 8 ) and ( pycor < 8 and pycor > 2 ) [ set pcolor red ]
if ( pxcor = 8 ) and ( pycor < -2 and pycor > -8 ) [ set pcolor red ]
end
to go
ask kids[
if pcolor = red and not any? other turtles-here[
move-to patch-here
stop]
fd 1
ifelse pcolor = red and any? other turtles-here
[rt random 90]
[fd 1]
]
ask adults[
if pcolor = red and not any? other turtles-here[
move-to patch-here
stop]
fd 1
ifelse pcolor = red and any? other turtles-here
[rt random 90]
[fd 1]
]
tick
end
you have already done most of the coding in the right way, I have tested your code and it works fine except your second condition in your go function for kids and adults.
One way to do the same thing is adding a turtle variable for example seated? Variable and make it false at initialization and make it true if the turtle is sitting on a bench. And only ask turtles with false seated? to look for another bench.
turtles-own [seated?]
ask kids with [not seated? ][
rt random 10
fd 1
if pcolor = red and not any? other turtles-here [
move-to patch-here
set seated? true]
]
ask adults with [not seated?]
[
rt random 10
fd 1
if pcolor = red and not any? other turtles-here[
move-to patch-here
set seated? true]
]
I have tested the code by showing number of turtles in each pacth and there was only one turtle per red patch
ask patches with [pcolor = red ][set plabel count turtles-here]

How to let some of the turtles move again?

In this model all it does is turtle will find a seat(red patch for available and yellow for taken). And once the seats are all occupied it all will stop.
Now how to make some of the turtles move again? Like if it is seated it will move again and try go another place or it will go out.
breed [kids kid]
breed [adults adult]
breed [oldies old]
kids-own [step]
adults-own [step]
oldies-own [step]
turtles-own [seated?]
to setup
__clear-all-and-reset-ticks
ask patches [setup-world]
ask patches with [pcolor = red ][set plabel count turtles-here]
set-default-shape turtles "person"
create-kids number-of-kids
create-adults number-of-adults
create-oldies number-of-oldies
ask kids[
set color green
set size 1
setxy -10 0
set heading random-float 90
rt 45 - random-float 90]
ask adults[
set color orange
set size 1
setxy -10 0
set heading random-float 45
rt 45 - random-float 90]
ask oldies[
set color blue
set size 1
setxy -10 0
set heading random-float 45
rt 45 - random-float 90]
end
to setup-world
set pcolor white
if ( pxcor = 10 ) and ( pycor < 10 and pycor > -11 ) [ set pcolor brown ]
if ( pxcor = -10 ) and ( pycor < 10 and pycor > 1 ) [ set pcolor brown ]
if ( pxcor = -10 ) and ( pycor < -1 and pycor > -11 ) [ set pcolor brown ]
if ( pycor = 10 ) and ( pxcor < 11 and pxcor > -11 ) [ set pcolor brown ]
if ( pycor = -10 ) and ( pxcor < 10 and pxcor > -11 ) [ set pcolor brown ]
if ( pxcor = 8 ) and ( pycor < 8 and pycor > 2 ) [ set pcolor red ]
if ( pxcor = 8 ) and ( pycor < -2 and pycor > -8 ) [ set pcolor red ]
end
to go
if count patches
with [pcolor = yellow and any? other turtles-here] = 10
[stop]
ask kids with [seated? = 0][
rt random 10
fd 2
if pcolor = red and not any? other turtles-here [
move-to patch-here
set seated? true
set pcolor yellow
]
]
ask adults with [seated? = 0]
[
rt random 10
fd 1.5
if pcolor = red and not any? other turtles-here[
move-to patch-here
set seated? true
set pcolor yellow
]
]
ask oldies with [seated? = 0]
[
rt random 10
fd 1
if pcolor = red and not any? other turtles-here[
move-to patch-here
set seated? true
set pcolor yellow
]
]
tick
end
Just the way you asked non-seated turtles by ask ... with [Seated? = 0] you can ask others by ask ... with [Seated? = 1]
However, I will suspect that they will go in a loop, because they are close to the bench ans bench is empty, so as soon as they stand up they will sit on the same spot again. Maybe you can have a memory [] which stores last few moves and if there is a seated position, say in last 10 items it will choose not to sit. I am not sure what are your requirements, this is just an example.
ask adults with [seated? = 1]
[
; Stand up set seated? = 0
; go around
]
ask kids with [seated? = 1]
[
; Stand up set seated? = 0
; go around
]
ask oldies with [seated? = 1]
[
; Stand up set seated? = 0
; go around
]
Update:
I have changed your code, its not much different from your code, but it has memory function to make sure turtles move around after leaving a bench and are not going to sit on same bench again and to some degree avoid walls (you need to improve the avoiding since step size is different for each agent):
breed [kids kid]
breed [adults adult]
breed [oldies old]
Globals [out-of-boundry]
turtles-own [seated? memory step]
to setup
clear-all
reset-ticks
ask patches [setup-world]
ask patches with [pcolor = red ][set plabel count turtles-here]
set out-of-boundry patches with [ pycor > 10 or pxcor < -10 or pxcor > 10 or pycor < -10 or pcolor = brown]
set-default-shape turtles "person"
create-kids 5 [
set memory []
set seated? false
set color green
set size 1
setxy -10 0
set heading random-float 90
rt 45 - random-float 90
set step 2
]
create-adults 5 [
set memory []
set seated? false
set color orange
set size 1
setxy -10 0
set heading random-float 45
rt 45 - random-float 90
set step 1.5
]
create-oldies 5 [
set memory []
set seated? false
set step 1
set color blue
set size 1
setxy -10 0
set heading random-float 45
rt 45 - random-float 90
]
end
to setup-world
set pcolor white
if ( pxcor = 10 ) and ( pycor < 10 and pycor > -11 ) [ set pcolor brown ]
if ( pxcor = -10 ) and ( pycor < 10 and pycor > 1 ) [ set pcolor brown ]
if ( pxcor = -10 ) and ( pycor < -1 and pycor > -11 ) [ set pcolor brown ]
if ( pycor = 10 ) and ( pxcor < 11 and pxcor > -11 ) [ set pcolor brown ]
if ( pycor = -10 ) and ( pxcor < 10 and pxcor > -11 ) [ set pcolor brown ]
if ( pxcor = 8 ) and ( pycor < 8 and pycor > 2 ) [ set pcolor red ]
if ( pxcor = 8 ) and ( pycor < -2 and pycor > -8 ) [ set pcolor red ]
end
to go
if count patches with [pcolor = yellow and any? other turtles-here] = 10 [stop]
ask turtles [
set memory lput Seated? memory
restrict-memory
ifelse seated?
[stand-up ]
[ move-in-the-brown-area step
sit]
]
tick
end
to move-in-the-brown-area [step-size]
ifelse not member? patch-ahead step-size out-of-boundry [
fd step-size
rt random 10
]
[ face one-of patches with [pcolor = white]
fd step-size
]
If member? patch-here out-of-boundry[
let target patch -10 0
face target
fd step-size]
end
to restrict-memory
;assume your memory-limit is 5
let memory-limit 5
if length memory >= memory-limit
[ set memory but-first memory ]
end
to stand-up
if seated?
[ set seated? false
set pcolor red
fd 1
]
end
to sit
if pcolor = red and not any? other turtles-here with [not member? true memory][
move-to patch-here
set seated? true
set pcolor yellow
]
end