如何让海龟根据拥有的特性按照排名移动顺序移动?
How do I make turtles move with ranked movement order based on an owned trait?
我正在尝试让海龟根据它们的分数(0-1 连续刻度)移动,这样分数越低移动越早。不幸的是,我完全没有想出有效的方法。制作海龟的代码是:
breed[a]
breed[s]
turtles-own [score]
set population 100
to make_turtles
create-s (population / 2)
[set color blue
set size 3
setxy random max-pxcor random max-pycor
set score random-normal 0.75 0.1
if score > 1 [set score 0.9999999999]
if score < 0.5 [set score 0.50000001]
]
create-a (population / 2)
[set color red
set size 3
setxy random max-pxcor random max-pycor
set score random-normal 0.25 0.1
if score < 0 [set score 0.00000000000001]
if score > 0.5 [set score 0.499999999999]
]
end
而且我让它们正常移动,我只需要它们按照 'score' 的顺序移动。预先感谢您提供任何提示!
您可能想按分数对海龟进行排序,然后遍历生成的列表,要求每只海龟移动。
foreach sort-on [score] turtles [ ask ? [ move]]
我正在尝试让海龟根据它们的分数(0-1 连续刻度)移动,这样分数越低移动越早。不幸的是,我完全没有想出有效的方法。制作海龟的代码是:
breed[a]
breed[s]
turtles-own [score]
set population 100
to make_turtles
create-s (population / 2)
[set color blue
set size 3
setxy random max-pxcor random max-pycor
set score random-normal 0.75 0.1
if score > 1 [set score 0.9999999999]
if score < 0.5 [set score 0.50000001]
]
create-a (population / 2)
[set color red
set size 3
setxy random max-pxcor random max-pycor
set score random-normal 0.25 0.1
if score < 0 [set score 0.00000000000001]
if score > 0.5 [set score 0.499999999999]
]
end
而且我让它们正常移动,我只需要它们按照 'score' 的顺序移动。预先感谢您提供任何提示!
您可能想按分数对海龟进行排序,然后遍历生成的列表,要求每只海龟移动。
foreach sort-on [score] turtles [ ask ? [ move]]