そのため、作成したレポーター プロシージャで計算したときに、その値でリストを並べ替えようとしています。コードは次のとおりです。
globals [ goal Smin Smax distWeight colorWeight ]
turtles-own [ S Ac ]
to setup
ca
set Smin 2
set Smax 6
set distWeight 2
set colorWeight 3
ask n-of n patches [
sprout 1 [
set color one-of [ red blue ]
set heading one-of [ 90 270 ]
set S []
]
]
reset-ticks
end
to go
ask turtles [
foreach sort other turtles [
ask ? [
if Smin < Sim myself ? [
if Sim myself ? < Smax [
set S lput ? S
]
]
]
]
;how do I do this? this does not work
set Ac max-one-of S [Sim myself ?]
]
tick
end
to-report Sim [Ame Ao]
report (Sfcolor Ame Ao * colorWeight) + (Sfdistance Ame Ao * distWeight)
end
to-report Sfcolor [Ame Ao]
ifelse [color] of Ame = [color] of Ao
[ report 1 ]
[ report 0 ]
end
to-report Sfdistance [Ame Ao]
report 1 / euclidean-distance [xcor] of Ame [ycor] of Ame [xcor] of Ao [ycor] of Ao
end
to-report euclidean-distance [x y x1 y1]
report sqrt ((x1 - x) ^ 2 + (y1 - y) ^ 2)
end
to-report Gain [ SimVal ]
report ( Smax - Smin ) / Smax - SimVal
end
Ac
ここで、Sim の最高値を持つ S の要素である亀を含む名前の変数が必要です。私はこれをやろうとしています
set Ac max-one-of S [Sim myself ?]
しかし、うまくいきません。