如何将 random-float 合并到命令中?网标
How incorporate random-float into a command? NETLOGO
To eat ;to kill prey and eat it
let kill one-of prey-here in-radius smell
;need to code in a variable for success too
if kill != nobody
[ask kill [ die ]
set energy energy + 10000]
end
目前这是我的命令,当我的乌龟在地图上 运行 进入它们时,它们会吃掉猎物。
我想添加一个变量,这样他们就有可能吃不到东西。我知道我需要使用 random-float 1
if random float is > .4 [what happens]
但我不知道在哪里将它添加到我的吃命令中以使其起作用。
有人可以指点一下吗?
我想你想要if random-float 1 > .4 [do something]
To eat ;to kill prey and eat it
let kill one-of prey-here in-radius smell
;need to code in a variable for success too
if kill != nobody
[ask kill [ die ]
set energy energy + 10000]
end
目前这是我的命令,当我的乌龟在地图上 运行 进入它们时,它们会吃掉猎物。
我想添加一个变量,这样他们就有可能吃不到东西。我知道我需要使用 random-float 1
if random float is > .4 [what happens]
但我不知道在哪里将它添加到我的吃命令中以使其起作用。
有人可以指点一下吗?
我想你想要if random-float 1 > .4 [do something]