Javier Sandoval
Javier Sandoval

Reputation: 507

NETLOGO: Count patches outside of certain radius

I want to count patches of a specific color starting at a patch radius end and outward. There is the in-radius command, but it considers the space between a patch center and its radius, but I want this space to be excluded and start counting where the radius ends. Any help is appreciated.

Javier

Upvotes: 0

Views: 612

Answers (1)

Luke C
Luke C

Reputation: 10291

How about a reporter that uses member? to return only a patch-set consisting only of patches that are not in-radius?

to setup
  ca
  ask n-of 10 patches [ set pcolor white ]
  crt 1 [ 
    setxy random-pxcor random-pycor 
    set color red
    set size 2
  ]
  reset-ticks
end

to go
  ask turtles [
    ask patches in-radius 5 with [ pcolor = black ] [ set pcolor black + 2 ]
    print count ( patches-outside-radius 8 ) with [ pcolor = white ]
  ]
end

to-report patches-outside-radius [ radius ]
  let inrad patches in-radius radius
  report patches with [ not member? self inrad ]
end

Upvotes: 3

Related Questions