如何将海龟的随机放置改为固定放置
How to change from Random placement of turtles to fixed placement
使用 setxy random-xcor random-ycor 将草(绿叶)随机放置在世界各地。我想要的是它的位置是固定的(例如,每片叶子每行间隔 10 个单位)。任何人都可以帮助我如何改变我的 setxy,或者有任何其他方法。非常感谢
也许 mod
取模运算符可以为您解决问题。例如:
to setup
ca
resize-world 0 50 0 50
ask patches with [ pxcor mod 10 = 0 and pycor mod 10 = 0 ] [
sprout 1 [
set shape "leaf"
set color green
]
]
reset-ticks
end
使用 setxy random-xcor random-ycor 将草(绿叶)随机放置在世界各地。我想要的是它的位置是固定的(例如,每片叶子每行间隔 10 个单位)。任何人都可以帮助我如何改变我的 setxy,或者有任何其他方法。非常感谢
也许 mod
取模运算符可以为您解决问题。例如:
to setup
ca
resize-world 0 50 0 50
ask patches with [ pxcor mod 10 = 0 and pycor mod 10 = 0 ] [
sprout 1 [
set shape "leaf"
set color green
]
]
reset-ticks
end