从 netLogo 中的 list/array 个字符串中选择一个随机元素
Pick a random element from list/array of strings in netLogo
我是 netlogo 的新程序员。我想知道如何从 netLogo 中的 list/array 个字符串中选择一个随机字符串?如果有人可以指导我,我将非常感激。谢谢
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
直接使用one-of
,例如:
print one-of [ "a" "b" "c" ]
将随机打印 "a"
、"b"
或 "c"
。
我是 netlogo 的新程序员。我想知道如何从 netLogo 中的 list/array 个字符串中选择一个随机字符串?如果有人可以指导我,我将非常感激。谢谢
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
直接使用one-of
,例如:
print one-of [ "a" "b" "c" ]
将随机打印 "a"
、"b"
或 "c"
。