Domanda

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

È stato utile?

Soluzione

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 ]
  ]
]
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top