您好,我有以下代码:
to go
move
play-papelvstije
play-papelvsrock
play-tijevsrock
play-tijevspapel
play-rockvspapel
play-rockvstije
end
to play-rockvspapel
ask turtles with [color = red]
[
let nearby other turtles in-radius 1
if any? nearby with [color = green]
[
set color green
]
]
end
to play-papelvstije
ask turtles with [color = green]
[
let nearby other turtles in-radius 1
if any? nearby with [color = blue]
[
set color blue
]
]
end
to play-tijevsrock
ask turtles with [color = blue]
[
let nearby other turtles in-radius 1
if any? nearby with [color = red]
[
set color red
]
]
end
to play-rockvstije
ask turtles with [color = red]
[
let nearby other turtles in-radius 1
if any? nearby with [color = blue]
[
set color red
]
]
end
to play-papelvsrock
ask turtles with [color = green]
[
let nearby other turtles in-radius 1
if any? nearby with [color = red]
[
set color green
]
]
end
to play-tijevspapel
ask turtles with [color = blue]
[
let nearby other turtles in-radius 1
if any? nearby with [color = green]
[
set color blue
]
]
end
正如你所看到的,我运行这个程序 play-papelvstije play-papelvsrock play-tijevsrock, play-tijevspapel, play-rockvspapel, play-rockvstije 以这个确切的顺序运行,所以当运行模拟时,我的结果会出现偏差,因为第一个运行的命令是最终人口增加的命令,所以我想做的是找到一种方法来运行这个程序,但只需一个命令。我尝试过使用“foreach”和“map”命令,但没有得到结果。有什么建议吗?