Reputation: 449
I would like to quantify how many times each turtle has passed each patch in the world. Do you know how I can get this information from NetLogo? I was able to find out how many times the turtle visited the patches, but not how many times it went to each specific patch. For example: turtle 0 visited patch (0, 0) 2 times and patch (0, 1) 4 times. But,Turtle 2 visited patch (0 0) 3 times and patch (0, 1) 3 times and so on.
But, the following error appears: Element 287 of list [0] could not be found, which is only 1. error while patch 7 22 running ITEM called by (anonymous command: [ id -> let item id turtle-visits set turtle-visits replace-item id turtle-visits current-num-visits + 1 ]) called by procedure GO called by 'go' button
Can someone help me?
globals [ edge-size ]
patches-own [ turtle-visits ]
to setup
ca
let num-turtles 1
set edge-size 29
resize-world 0 edge-size 0 edge-size
let pcolors []
set pcolors [ 85 95 ]
ask patches [
set turtle-visits n-values num-turtles [0]
set pcolor item (random 2) pcolors
]
reset-ticks
end
to go
ask turtles [
rt random 360
fd 1
]
end
Upvotes: 0
Views: 50
Reputation: 1181
The problem is, that you initialize the list of turtle-visits
with the number of turtles per patch, i.e num-turtles
:
set turtle-visits n-values num-turtles [0]
If you replace num-turtles
with count turtles
, since you want a value for every turtle in the world, it should work:
set turtle-visits n-values count turtles [0]
Upvotes: 2