Each Turtle need to pick different agents from the same agentset - netlogo

i got a problem with my breed (amministrazione spurgatori).
I need each one of them to pick a different target from the same agentset (manholes with segnalato? = true) but they all head to the same patch.
I think the problem is the code in "to direzione amministrazione" but i am not sure.
Any suggestions?
Thank you in advance
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;; CARATTERISTICHE ;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
globals
[
grid-x-inc ;;per definire la grandezza degli isolati (quadrati verd)
grid-y-inc
intersections
manholesO ;; tombini sulle strade orizzontali
manholesV ;; tombini sulle strade verticali
roads
valore-Scenario-degrado
]
turtles-own
[
ufficio
segnalati
work
house
goal
speed
applicazione?
]
breed [cittadini cittadino]
breed [amministrazione spurgatore]
patches-own
[
intersection? ;;vero se è intersezione tra due strade ;;vero se è tombino
ostruzione-da-rifiuti ;; da definire bene
segnalato?
]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;; PROCEDURA DI SETUP ;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
to setup
ca
reset-ticks
setup-globals
setup-patches
set-Scenario-Degrado
let goal-candidates patches with [
pcolor = 37 and any? neighbors with [ pcolor = white]
]
create-cittadini n-of-cittadini
[
set size 1
set color black
set shape "car"
set speed 0.07
set house one-of goal-candidates ;;crea la tartaruga casa
set work one-of goal-candidates with [ self != [ house ] of myself] ;;crea una localizzazione diversa per ogni tartaruga
set goal work ;;crea direzione attuale
move-to house
set applicazione? false
]
ask n-of NOALLATESSERADELTIFOSO cittadini [set applicazione? true]
create-amministrazione n-of-spurgatori
[
set size 1
set color red
set shape "person"
set speed speed
set ufficio one-of goal-candidates
set goal ufficio
move-to ufficio
]
end
;;con setup globals si definiscono le dimensioni della griglia in questo caso non è modificabile
to setup-globals
set grid-x-inc world-width / 7
set grid-y-inc world-height / 7
end
;;con ask patches definisco le pacth che rappresentano i quadrati intorno alle strade con set road le strade
to setup-patches
ask patches ;;caratteristiche generali delle patch verdi
[ set intersection? false
set pcolor 37
]
set roads patches with ;;definisco quali sono le strade attraverso le coordinate
[(floor((pxcor + max-pxcor - floor(grid-x-inc - 0))
mod grid-x-inc) = 0) or
(floor((pycor + max-pycor) mod grid-y-inc) = 0)]
ask roads [ set pcolor white ]
;;vado a definire le intersezioni, capire bene
set intersections roads with ;; definisco quali sono le intersezioni attraverso le coordinate
[(floor((pxcor + max-pxcor - floor(grid-x-inc - 0)) mod grid-x-inc) = 0) and
(floor((pycor + max-pycor) mod grid-y-inc) = 0)]
set manholesO roads with ;;definisco quali sono i tombini sulle strade orizzonatli
[(floor((pxcor + max-pxcor - floor(grid-x-inc - 0)) mod grid-x-inc) = 4) and
(floor((pycor + max-pycor) mod grid-y-inc) = 0 )]
set manholesV roads with ;;definisco quali sono i tombini sulle strade verticali
[(floor((pycor + max-pycor - floor(grid-y-inc - 0)) mod grid-y-inc) = 4) and
(floor((pxcor + max-pxcor) mod grid-x-inc) = 0 )]
setup-intersections
setup-manholesO
setup-manholesV
end
to setup-intersections
ask intersections
[
set intersection? true
]
end
to setup-manholesO
if setup-manholes? [
ask manholesO
[ set pcolor 109
set segnalato? false
set ostruzione-da-rifiuti 0
]
]
end
to setup-manholesV
if setup-manholes? [
ask manholesV
[ set pcolor 109
set segnalato? false
set ostruzione-da-rifiuti 0
]
]
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;; PROCUDERA DI AVVIO ;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:
to go
tick
network
go-cittadini
go-amministrazione
ask manholesO [ ;;il tempo di svuotamento aumento di 1 ogni tick
ostruzioneO
]
ask manholesV
[
ostruzioneV
]
attappamento
end
to network
if Metodo-diffusione-applicazione = "Passaparola"
[
ask cittadini with [applicazione? = true]
[if any? cittadini in-radius 1 with [applicazione? = false] and random-float 1.0 < Probabilità-connessione
[create-link-with one-of other cittadini in-radius 1 with [ applicazione? = false ]
]
]
]
end
to segnalazione
ask cittadini with [applicazione? = true]
[
if [pcolor] of patch-ahead 2 = 103 [
ask patch-ahead 2 [set segnalato? true]
]
]
end
to go-cittadini
ask cittadini
[face next-patch ;;per andare verso la direzione quindi definisce il movimento (forse non serve up-car?)
fd speed
variation-speed
direzione-cittadini
segnalazione
ask link-neighbors [ set applicazione? true ]
]
ask cittadini with [applicazione? = true][ ask in-link-neighbors
[ set applicazione? true]
]
end
to go-amministrazione
ask amministrazione
[
face next-patch2
fd 0.05
direzione-amministrazione
]
end
to direzione-cittadini
if goal = house and (member? patch-here [ neighbors4 ] of house) [ set goal work ]
if goal = work and (member? patch-here [ neighbors4 ] of work) [ set goal house ]
end
to direzione-amministrazione
set segnalati patches with [segnalato? = true]
if not any? patches with [segnalato? = true] [set goal ufficio]
if any? patches with [segnalato? = true ] [set goal one-of segnalati]
if count patches with [segnalato? = true] > 1 [
set goal min-one-of (patches with [segnalato? = true]) [distance myself]
]
spurgo
end
to spurgo
ask amministrazione [
if [segnalato?] of patch-here = true [
set ostruzione-da-rifiuti 0
set segnalato? false
]
]
end
to variation-speed
if rain? [
ifelse [pcolor] of patch-ahead 2 = 103
[set speed 0]
[ifelse pcolor = 107
[set speed 0.025]
[set speed 0.05]
]
]
end
to ostruzioneO ;; il tombino cambia colore in base al livello di ostruzione
if setup-manholes? [
ifelse ostruzione-da-rifiuti >= 600
[ifelse ostruzione-da-rifiuti >= 1200
[set pcolor 103]
[set pcolor 107]
]
[set pcolor 109]
]
end
to ostruzioneV ;; il tombino cambia colore in base al livello di ostruzione
if setup-manholes? [
ifelse ostruzione-da-rifiuti >= 600
[ifelse ostruzione-da-rifiuti >= 1200
[set pcolor 103]
[set pcolor 107]
]
[set pcolor 109]
]
end
to attappamento
ask cittadini [ if any? cittadini-on manholesO [set ostruzione-da-rifiuti ostruzione-da-rifiuti + valore-Scenario-degrado] ]
ask cittadini [ if any? cittadini-on manholesV [set ostruzione-da-rifiuti ostruzione-da-rifiuti + valore-Scenario-degrado] ]
end
to set-Scenario-degrado
if Scenario-degrado = "Basso" [
set valore-Scenario-degrado random-float (2 - 0) + 0
]
if Scenario-degrado = "Medio" [
set valore-Scenario-degrado random (4 - 2) + 2
]
if Scenario-degrado = "Alto" [
set valore-Scenario-degrado random-float (6 - 4) + 4
]
end
to-report next-patch
let choices neighbors with [ pcolor = white or pcolor = 109 or pcolor = 107 or pcolor = 103] ;;qui per farli passare sui tombini modificare con i colori che si impostano
let choice min-one-of choices [ distance [goal] of myself ] ;;fai fare la distanza alla tartaruga
report choice
end
to-report next-patch2
let choices neighbors with [ pcolor = white or pcolor = 109 or pcolor = 107 or pcolor = 103 ] ;;qui per farli passare sui tombini modificare con i colori che si impostano
let choice min-one-of choices [ distance [goal] of myself ] ;;fai fare la distanza alla tartaruga
report choice
end

First, please edit your question rather than write an answer with your updates. Here is a cleaner version of your code.
to go-amministrazione
ask amministrazione
[ face next-patch2
fd 0.05
direzione-amministrazione
]
end
to direzione-amministrazione
set segnalati patches with [segnalato?]
if-else any? segnalati
[ set goal one-of segnalati
set goal min-one-of segnalati [distance myself]
]
[ set goal ufficio ]
spurgo
end
What I have done is:
replaced first patches with [segnalato? = true] with patches with [segnalato?] - you don't need the =true bit (and you can say not instead of =false too)
replaced all the other patches with [segnalato? = true] with segnalati (since you actually define this patch-set - once it's defined, you should just use the name so that NetLogo doesn't have to keep recreating the patch-set to count it
recognise that if there's only one segnalato then it's also the closest segnalato
combine the logic flow into a single if-else statement so NetLogo only has one truth test to assess rather than three
Looking at this code, you can obviously delete the line set goal one-of segnalati and have the same effect.
Having said all that, I can't see anything logically wrong with this code. Each amministrazione should be choosing the closest segnalato as its goal.
What I would do is create many more segnalato and then manually inspect several amministrazione that are near a segnalato to see whether it is choosing the correct one. It may be that you happened to create your segnalato in locations that are not near any amministrazione to so the amministrazione end up mostly choosing the same segnalato because it happens to be central.

Related

How to restrict Old vs. Young: in netlogo?

I am trying to simulate the following situation. Young and old agents.
The old have few social contacts, slower and at the same time have a greater chance of dying.
Young people have more contacts .
Which group should be vaccinated first ?
I created two groups, assigned an infection algorithm, and assigned a social distance. But at the same time I do not see the relationship, the agents behave identically, where is the error?
I'm a beginner and don't want to complicate the model. please don't answer difficult I'm just learning
my code
;;breed [humans human]
;;humans-own [ old young ]
breed [young p-young]
breed [old p-old]
young-own [
days-after-infected
days-of-sick
]
old-own [
days-after-infected
days-of-sick ]
to setup
clear-all
setup-old
setup-young
setup-patches
reset-ticks
end
to setup-old
create-old population-old
[
setxy random-xcor random-ycor
set color 4
set shape "person"
]
end
to setup-young
create-young population-young
[
setxy random-xcor random-ycor
set shape "person"
set color 96
]
end
to setup-patches
ask patches [set pcolor 61]
end
;:ask old [random 360]
;;ask young [forward 1]
to go
move-old
move-young
transmission-old
transmission-young
incubation
sickness
tick
end
to move-old
ask old [
right random 360
forward 1
]
end
to move-young
ask young [
right random 360
forward 3
]
end
to add-carrier
ask one-of young
[set color orange]
end
to transmission-old
ask young with [color = orange]
[let susceptible-person one-of old in-radius 3 with [color = 4]
if susceptible-person != nobody
[ask susceptible-person
[if random 100 < transmission_rate
[set color orange]
]
]
]
end
to transmission-young
ask young with [color = orange]
[let susceptible-person one-of young in-radius 2 with [color = 96]
if susceptible-person != nobody
[ask susceptible-person
[if random 100 < transmission_rate
[set color orange]
]
]
]
end
to incubation
ask old with [color = orange]
[ ifelse days-after-infected < incubation_period
[set days-after-infected days-after-infected + 1]
[set color red]
]
ask young with [color = orange]
[ ifelse days-after-infected < incubation_period
[set days-after-infected days-after-infected + 1]
[set color red ]
]
end
to sickness
ask old with [ color = red ]
[ifelse days-of-sick < 14
[set days-of-sick days-of-sick + 1]
[ifelse random 100 < mortality
[die]
[ set color blue ]
]
]
ask young with [ color = red ]
[ifelse days-of-sick < 14
[set days-of-sick days-of-sick + 1]
[ifelse random 100 < mortality
[die]
[ set color blue ]
]
]
end
I am trying to infect some agents from others, while I am not interested in the incubation period and trying to link age (less movement and less contact) with morbidity.
But I see that the result is not presentable, there is no dependence on age and morbidity.
The transmission-old is your problem. You copypasted from transmission-young but forgot to replace ask young with ask old
to transmission-old
ask old with [color = orange]
[let susceptible-person one-of old in-radius 3 with [color = 4]
if susceptible-person != nobody
[ask susceptible-person
[if random 100 < transmission_rate
[set color orange]
]
]
]
end
I've been fighting for a week, I changed the concept, I think it's easier. How to describe the last block. If there is one infectious neighbor, he will transmit his infection with faithfulness....
breed [olds humanA]
breed [youngs humanB]
globals
[
humans
]
to setup
clear-all
create-olds humans_number * shareA
[
set color 64
set xcor random-xcor
set ycor random-ycor
set shape "person"
]
create-youngs humans_number * (1 - shareA)
[
set color 45
set xcor random-xcor
set ycor random-ycor
set shape "person"
]
set humans (turtle-set olds youngs)
ask olds
[
create-links-with (up-to-n-of (links_number_old * homophily_old) (other olds))
create-links-with (up-to-n-of (links_number_old * ( 1 - homophily_old)) (other
humans))
]
ask youngs
[
create-links-with (up-to-n-of (links_number_young * homophily_young) (other
youngs))
create-links-with (up-to-n-of (links_number_young * ( 1 - homophily_young))
(other humans))
ask patches
[
]
ask n-of 1 humans
[
set infected 1
set color red
]
reset-ticks
end
*to go
ask humans
[
if any? link-neighbors != red ]
[
set humans ......*
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

make turtles move only on specific patches

I"m fairly new at netlogo so it might seem like a dumb question but here it is :
I have a world with patch with specific attributes that represents parks, buildings, streets (2 types small and large), etc. I want my turtles to move towards a specific point (I managed to do that) using only the patches representing streets but with a tendency to move towards parks and green spaces.
I was wondering if you could help me to make them use only the patches representing the streets.
here is the way I set up my world and created my turtles :
extensions
[
gis
]
globals
[
Batiments
ChemindeFer
Cimetiere
Densite
Eau
Ponts
Routes
TerrainSports
Vegetations
]
patches-own
[
Cheminferroviaire
Bati
pont
TerraindeSport
Vege
cimetary
water
road
densitepop
Npatchvert
]
breed [ Renards renard]
breed [ Proies proie]
Renards-own
[
stress
poids
]
Proies-own
[
weight
]
to setup
ca
initialiserGIS
creerRenard
creerProie
move
reset-ticks
end
to initialiserGIS
; ---------------------- chargement densité ----------------------------
set Densite gis:load-dataset "desite_ind_g.asc"
gis:apply-raster Densite densitepop
let min-Densite gis:minimum-of Densite
let max-Densite gis:maximum-of Densite
ask patches
[
ifelse densitepop >= 1.5
[ set pcolor scale-color grey densitepop 1.5 6]
[ set pcolor white ]
]
;------------------- chargement des chemin de fer ----------------
set ChemindeFer gis:load-dataset "chdefer_g.asc"
gis:apply-raster ChemindeFer Cheminferroviaire
ask patches with [Cheminferroviaire = 1]
[set pcolor grey]
;--------------------- chargement batiments --------------------
set Batiments gis:load-dataset "batiment_g.asc"
gis:apply-raster Batiments Bati
ask patches with [Bati = 1]
[set pcolor brown]
;--------------------- chargement des ponts --------------------
set Ponts gis:load-dataset "ponts_g.asc"
gis:apply-raster Ponts pont
ask patches with [ pont = 1]
[set pcolor 87]
;--------------------- chargement de l'eau ----------------------
set Eau gis:load-dataset "eau_g.asc"
gis:apply-raster Eau water
ask patches with [ water = 1]
[set pcolor blue]
;--------------------- sports field -----------------
set TerrainSports gis:load-dataset "terrain_sport_g.asc"
gis:apply-raster TerrainSports TerraindeSport
ask patches with [ TerraindeSport = 1]
[set pcolor green]
;--------------------- végétation --------------------
set Vegetations gis:load-dataset "vegetation_g.asc"
gis:apply-raster Vegetations Vege
ask patches with [ vege = 1 ]
[set pcolor green]
;--------------------- cimetary --------------------
set Cimetiere gis:load-dataset "cimetiere_g.asc"
gis:apply-raster Cimetiere cimetary
ask patches with [ cimetary = 1 ]
[set pcolor green]
;---------------------- roads ---------------------------
set Routes gis:load-dataset "routes_g.asc"
gis:apply-raster Routes road
ask patches with
[ road = 4] [set pcolor 87]
ask patches with
[ road = 3] [set pcolor 104]
ask patches with
[ road = 0] [set pcolor green]
end
to creerRenard
create-Renards 10
end
to move
; --- 1st mouvement (towards campus) ---
ask renards
[ set heading towardsxy 10 101
fd 1 ]
end
I hope this isn't too much information ... Thank you in advance !

How can i make my model count ticks faster vs the actions they are doing using NetLogo?

I'm modeling a critical situation that's happening in my city (Viña del Mar, Chile), where the "metro" (subway)can have serious problems if a tsunami occurs because the evacuation exits are not well prepared nor well managed.
This example is a simple model of the real one, but i was having really big problems trying to make the turtles move from the subway (blue patches), using the door (lime patch) and then jumping into the railways (gray patches). When i finally made them do those actions i found 2 problems: (1) the ticks aren't working the way i need them to work. I need it to run like it was a clock, counting seconds. (2) i create 3 actions called "check-vecinos-azul/lime/gray" where they need to check if there's any turtle arround them (neighbors). If there's an empty space arround a turtle it moves to that empty spot, otherwise it stands until it finds an empty one.
I'd be so glad if anyone of you could give me a help/tip with my model.
Thank you guys,
Kind regards,
Felipe.
breed [pasajeros pasajero]
turtles-own [
distancia
speed
speed-limit
speed-min
evacuacion
]
patches-own
[
pvacio
]
to setup
ca
setup-patches
setup-pasajeros
reset-ticks
end
to setup-patches
ask patches with [pycor <= 0]
[set pcolor blue - 1]
ask patches with [pycor > 0]
[set pcolor gray + 2]
ask patch 0 0 [set pcolor lime]
end
to setup-pasajeros
ask n-of num-pasajeros (patches with [pcolor = blue - 1])
[
sprout-pasajeros 1
[set size 1
set color orange
set speed 0.1 + random-float 0.9
set speed-limit 1
set speed-min 0
set evacuacion 0
]
]
end
to go
ask pasajeros [
ifelse evacuar?
[
go-puerta
salir-puerta
move-chancado
]
[
stop
]
]
tick
end
to go-puerta
ask turtles with [pcolor = blue - 1]
[
set evacuacion 1
if evacuacion = 1
[
check-vecinos-azul
face min-one-of patches with [pcolor = lime][distance myself]
fd speed ;;
]
]
end
to salir-puerta
ask turtles with [pcolor = lime]
[
set evacuacion 1
if evacuacion = 1
[
check-vecinos-lime
face min-one-of patches with [pcolor = gray + 2][distance myself]
fd speed
]
]
end
to move-chancado
ask turtles with [pcolor = gray + 2]
[
set evacuacion 1
check-vecinos-gray
]
end
to check-vecinos-azul
ifelse not any? turtles-on one-of neighbors
[
wait 0
move-to min-one-of patches with [pcolor = blue - 1][distance myself]
fd speed
]
[
wait 0.5
]
end
to check-vecinos-lime
ifelse not any? turtles-on one-of neighbors
[
wait 0
face one-of patches with [pcolor = gray + 2]
fd speed
]
[
wait 0.5
]
end
to check-vecinos-gray
ifelse not any? turtles-on one-of neighbors
[
wait 0
face min-one-of patches with [pcolor = gray + 2][distance myself]
fd speed
]
[
wait 0.5
]
end

Color progression issue in netlogo

I have three different turtles: red, white, and green. I am trying to get these turtles to couple up (like people in relationships) and then uncouple. While a red turtle is coupled with a green or white turtle I want the patch color to sometimes randomly change colors, but for some reason the patch color color progression is not working.
to go
ask turtles
[ if coupled? = true
[ set couple-length couple-length + 1 ] ]
ask turtles
[ if coupled? = false
[ move ] ]
ask turtles
[ if coupled? = false and shape = "person righty" and (random-float 10.0 < coupling-tendency)
[ couple ]
let potential-intervener one-of (turtles-on neighbors) with [ green-dotter? = true]
if (coupled? = true and potential-intervener != nobody and "person righty" = true)
[ifelse (random-float 10.0 < resting-tendency)
[;;decides to stay
ask potential-intervener [move-to patch-here] ;; this is possibly what is causing the lack of intervention?
; does not intervene, start the color progression
ifelse (random-float 10.0 < intervening-tendency)
[;; intervenes
uncouple
]
[set couple-length couple-length + 1 ;; increments the couple length by 1
if (couple-length = 2)
[
ask patch-here [set pcolor yellow]
ask patch-at -1 0 [set pcolor yellow] ]
if (couple-length = 4)
[
ask patch-here [set pcolor orange]
ask (patch-at -1 0) [set pcolor orange] ]
if (couple-length = 6)
[
ask patch-here [set pcolor red]
ask (patch-at -1 0) [set pcolor red] ] ]
]
[
;;decides to move
ask potential-intervener [move]
set couple-length couple-length + 1 ;; increments the couple length by 1
if (couple-length = 2)
[
ask patch-here [set pcolor yellow]
ask patch-at -1 0 [set pcolor yellow] ]
if (couple-length = 4)
[
ask patch-here [set pcolor orange]
ask (patch-at -1 0) [set pcolor orange] ]
if (couple-length = 6)
[
ask patch-here [set pcolor red]
ask (patch-at -1 0) [set pcolor red] ] ]
]
; will green dotter intervene?
ifelse (random-float 10.0 < intervening-tendency)
[;; intervenes
uncouple
]
[;; does not intervene, start the color progression
set couple-length couple-length + 1 ;; increments the couple length by 1
if (couple-length = 2)
[
ask patch-here [set pcolor yellow]
ask patch-at -1 0 [set pcolor yellow] ]
if (couple-length = 4)
[
ask patch-here [set pcolor orange]
ask (patch-at -1 0) [set pcolor orange] ]
if (couple-length = 6)
[
ask patch-here [set pcolor red]
ask (patch-at -1 0) [set pcolor red] ] ]
]
check-sliders
tick
end
For one thing, your line if (coupled? = true and potential-intervener != nobody and "person righty" = true) is inside a command block that is only reached through if coupled? = false and shape = "person righty" and (random-float 10.0 < coupling-tendency). That is, it doesn't get reached because coupled? would need to be both true and false. Better formatting would make this immediately clear. I have reformatted the top part of your code so you can see this:
to go
ask turtles
[ ifelse coupled?
[ set couple-length couple-length + 1 ] ]
[ move
if shape = "person righty" and (random-float 10.0 < coupling-tendency)
[ couple ]
let potential-intervener one-of (turtles-on neighbors) with [ green-dotter?]
if (coupled? and potential-intervener != nobody and "person righty")
[ ifelse (random-float 10.0 < resting-tendency)
[;;decides to stay
ask potential-intervener [move-to patch-here]
A couple of other notes. You don't need to say if coupled? = true, it is sufficient to say if coupled?. Since you have the same colouring code three times, it would be better to have it only once as a separate procedure and call it from the three locations, so it is much easier to change.