Turbonis
Turbonis

Reputation: 15

NetLogo how to count turtles in a coordinate

im doing an evacuation model which will compare the time to take if ull take the nearest exit or go with the crowd. What i have done so far is to simulate the" nearest exit"

to go

ask turtles [sideway]

end

to sideway

if pxcor < 0 [ set heading 270 ]                                                           
  if pxcor > 0 [ set heading 90 ]

end

this is just apseudocode. now my question is that how to count the number of turtles in pxcor >0 and pxcore<0?

example

if pxcor > 0
counter ++;

Upvotes: 0

Views: 288

Answers (1)

Bryan Head
Bryan Head

Reputation: 12580

count turtles with [ pxcor > 0 ]

turtles is just all the turtles. turtles with [ pxcor > 0 ] creates a new set that contains just the turtles from turtles for which pxcor > 0 is true. count just counts the number of agents in a set.

Upvotes: 1

Related Questions