Ask up to n-of turtles

假装没事ソ 提交于 2019-12-23 19:04:03

问题


Is there a built in function that will ask up to n-of turtles? So if you ask 50 turtles but there are only 40 it will ask those 40 and move on. Or there aren't any, it will just move on.

Alternatively does anyone have any neat code for achieving this?


回答1:


This will pick out 40 random turtles:

ask n-of 40 turtles [ <whatever you want them to do> ]

If you want to pick out a smaller number when there are not 40 available, you could do something like:

let num min (list 40 count turtles)
ask n-of num turtles [ <whatever you want them to do> ]


来源:https://stackoverflow.com/questions/35697025/ask-up-to-n-of-turtles

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