I just started using NetLogo and I'm trying to transition away from OOP, so I apologize if my coding paradigm is the source of my issue.
Problem
Inside an ask turtle
procedure I want each turtle to call a method passing itself to it as a parameter. I get en error: Expected a number rather than a list or block
.
Attempts to solve the problem
ask turtles [
setxy ( mean [pxcor] of my-territory ) ( mean [pycor] of my-territory )
show my-territory
report-status-and-split turtle [[who] of myself]
]
and i'm using it as:
report-status-and-split [reporting-turtle]
...
create-turtles 1 [
set color red
if reporting-turtle != nobody
[ create-link-with reporting-turtle [ set color green ]
move-to reporting-turtle
fd 8
]
]
I have also tried: report-status-and-split [who myself]
and report-status-and-split [myself [who]]
. All have an error of Expected a literal
.
So instead of using who
, if I try to just pass myself
as a parameter I get:
You can't use REPORT-STATUS-AND-SPLIT in a turtle context, because REPORT-STATUS-AND-SPLIT is observer-only.
I'm sure my issue is simple.
How can I properly use who
with turles inside the ask-turtle context?
Or how can rethink my approach to follow Netlogo's coding practices?
Aucun commentaire:
Enregistrer un commentaire