Make turtles move ONCE according to their ranked order in a list

偶尔善良 提交于 2019-12-06 15:17:48

In the line:

ask turtles [foreach rank-list [ask ? [set heading 270 forward 1]]]

You're asking each turtle to execute a command for each turtle in your rank-list.

Just drop the ask turtles part.

As a more general note: foreach is to lists what ask is to agentsets. They both do the same basic thing, which is to perform a command for each item of a "collection". Agentsets are unordered collections of unique agents. Lists are ordered collections of possibly duplicated items of any type.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!