从netLogo中的列表/字符串数组中选择一个随机元素

时间:2016-07-28 02:19:58

标签: arrays string list random netlogo

我是netlogo的新程序员。我想知道如何从netLogo中的字符串列表/数组中选择一个随机字符串?如果有人能指导我,我将非常感激。感谢

PS:我已经做了很多努力,我只知道如何从像这样的数字范围中选择一个随机数

random-float (PRICE * 0.20) ;For float value (price is an integer defined by me)
random round (DifferenceAmt * 0.10) ; For random rounded amount

1 个答案:

答案 0 :(得分:3)

只需使用one-of,例如:

print one-of [ "a" "b" "c" ]

会随机打印"a""b""c"