Question

I need to do a netlogo program to create the following scenario.

If two turtles come to a single patch they must die and hatch a new turtle with size 2. How can I do this in netlogo?

My idea is to count the turtles in each patch and if that number is 2 then kill them and hatch new one. Can someone provide me the code to count the turtles in each patch? Thanks

Was it helpful?

Solution

You'll get nicer reading code if you change your breed declaration to:

breed [men man]

specifying both the plural and the singular forms.

Then, it's:

ask patches [
  if count men-here = 2 [
    ask men-here [ die ]
    sprout-men 1 [ set size 2 ]
  ]
]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top