문제

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

도움이 되었습니까?

해결책

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 ]
  ]
]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top