I'm getting an error message saying expected command in 'choose-exit'
and the issue seems to be in the line "choose-exit patch-here" within the "initialize-passengers" procedure. I've checked the code and everything seems correct, so I'm not sure what could be causing the problem.
breed [ passengers passenger]
breed [ fire-spots a-fire-spot]
breed [ smoke-spots a-smoke-spot]
globals [ exit1 ;; pID
exit2 ;; pID
exits-list ;; [ pID ... ]
passenger_count ;; integer
]
passengers-own [ in-seat? ;; boolean
safe? ;; boolean
dead? ;; boolean
panic? ;; boolean
current-heading ;; turtleHDG
target-exit ;; pID
my-exits-list ;; [ pID ... ]
item? ;; boolean
]
patches-own [ accessible? ;; boolean
fire? ;; boolean
]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FUNZIONI SETUP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
to setup
__clear-all-and-reset-ticks
;;;;;; DEBUG
type "----------------------------[SETUP]\n"
;;;;;; DEBUG
initialize-globals
initialize-train
initialize-exits
initialize-passengers
; initialize-fire
reset-ticks
end
to initialize-globals
set exit1 patch 64 -13
set exit2 patch 13 -54
set exits-list ( list exit1 exit2 )
end
to initialize-train
import-pcolors "C:/Users/palli/OneDrive/Desktop/Modello_base/images/ambiente.png"
ask patches [
if pcolor = 86.6 [set pcolor cyan]
if pcolor = 0 [set pcolor black]
if pcolor = 64.3 [set pcolor green]
if pcolor = 9.9 [set pcolor white]
set fire? false
set accessible? false ; Imposta tutte le patch come inaccessibili di default
]
ask patches with [pcolor = white] [
set accessible? true ; Contrassegna le patch verdi come accessibili
]
end
to initialize-exits
set exit1 patch 64 -13
set exit2 patch 13 -54
set exits-list (list exit1 exit2)
end
to initialize-passengers
create-passengers passenger-count [
set shape "person business"
set size 2
set color yellow
set in-seat? false ; Cambia da true a false
set safe? false
set dead? false
set panic? true
set current-heading 0
set my-exits-list [] ; SET here, it must assign a []-list to this property BEFORE next call to choose-exit
set target-exit nobody ; SET this as the initial target-exit
; Aggiungi il seguente blocco di codice per posizionare casualmente i passeggeri in patch accessibili
let target one-of patches with [accessible?]
move-to target
set target-exit choose-exit patch-here ; Aggiorna il target-exit dopo esserti spostato sulla patch iniziale
]
end
to-report choose-exit [current-position] ;; still ignore the passed parameter-value
let possible-exits []
let shortest-distance 10000
let nearest-exit nobody
foreach exits-list [ exitUnderTest ->
let exit-coords (list [pxcor] of exitUnderTest [pycor] of exitUnderTest) ;; Get exit coordinates as a list
let exit-distance distance exitUnderTest
if exit-distance < shortest-distance [
set shortest-distance exit-distance
set nearest-exit exitUnderTest
set possible-exits []
]
if exit-distance = shortest-distance [
set possible-exits lput exit-coords possible-exits ;; Use exit coordinates instead of the patch object
]
]
if length possible-exits = 0 [
print "No exits found."
report nobody
]
let lucky-exit-coords one-of possible-exits
let lucky-exit patch-at ( item 0 lucky-exit-coords )
( item 1 lucky-exit-coords ) ;; Get the object using the coordinates
set target-exit lucky-exit
set my-exits-list lput lucky-exit my-exits-list
report lucky-exit
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; FUNZIONI GO ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
to go
;;;;;; DEBUG
type "----------------------------[GO.tick]\n"
;;;;;; DEBUG
ask passengers [
if panic? [
let target-to-exit choose-exit patch-here
face target-to-exit
]
move
]
tick
end
;;;go()
to move
if panic? [
move-to target-exit
if patch-here = target-exit [
set safe? true
set in-seat? false
]
]
end
;;;move()
I have solved the previous 2 problems, This problem occurred to me, the passengers move but do not go towards the exit in a smart way and remain in the centre moving around, they also move out of the edge of the room. How can I solve it?