1

I'm programming a simulation using repast simphony groovy API.

There's a method count(myTurtles) which allows me to count the number of agents (turtles) of a particular class myTurtle extends BaseTurtle.

My question is: Is there any way to filter this count so I can only get the turtles matching a particular value for a property (shape, color, size...)?

tim_yates
  • 167,322
  • 27
  • 342
  • 338
NotGaeL
  • 8,344
  • 5
  • 40
  • 70

1 Answers1

2

No idea about Repast Simphony (and the documentation for the groovy aspect of it seems sparse at best), but in Groovy, if you have a list of objects, you can find all the objects that have a matching property by using:

def filteredList = list.findAll { it.color == 'red' }
tim_yates
  • 167,322
  • 27
  • 342
  • 338