Why does the Agentset button behave differently than the watcher button requesting an agent?

I see a difference in behavior between the agent button (patch, turtle, link), which launches a specific section of code and the observer button, which ask patches (or turtles or links ), launches the same section of code. Is this a bug in NetLogo? Is this a bug in my code?

+5
source share
1 answer

The reason for the difference in behavior is not really a bug, but a rather hidden corner of NetLogo. ask-concurrent primitive underlies this behavior. The agentet button uses the same mechanism as ask-concurrent backstage. Replacing any agent button with an observer button that uses ask-concurrent to run the same code in the same agent should not change the behavior of the button.

Usually the differences between ask and ask-concurrent not significant. Turtles can move a little differently, but they will work basically the same. In some cases, however, the differences can be truly dramatic. The NetLogo Model Library provides a model called the Ask-Concurrent Example, which discusses the differences between ask and ask-concurrent .

The NetLogo Programming Guide has documentation in the "Turtle, Patch and Link to the Eternal Buttons" section http://ccl.northwestern.edu/netlogo/docs/programming.html#buttons ; a significant portion of the ask-concurrent section of http://ccl.northwestern.edu/netlogo/docs/programming.html#ask-concurrent also applies.

Note Using ask-concurrent not recommended. I use it here to clarify the behavior, but it should not be used at all.

Note 2 In general, the safest and most predictable approach is to not use the turtle, patch, and link buttons. Instead, use only the observer buttons and use ask turtles , ask patches or ask links in the button code, if necessary.

+5
source

Source: https://habr.com/ru/post/1240461/


All Articles