breed
является атрибутом черепахи точно так же, как и другие встроенные переменные (например, size
) или переменные, определенные с помощью оператора turtles-own
. Это означает, что вы можете напрямую проверить с помощью [breed] of
.
Вот полный пример, который проверяет breed
выбранной черепахи с именем target и меняет ее цвет.
breed [type1s type1]
breed [type2s type2]
to setup
clear-all
create-type1s 20
[ setxy random-xcor random-ycor
set color red
]
create-type2s 20
[ setxy random-xcor random-ycor
set color yellow
]
ask one-of turtles
[ set size 2
let target min-one-of other turtles [distance myself]
if [breed] of target = type1s [ask target [set color white]]
if [breed] of target = type2s [ask target [set color blue]]
]
end
Вы также можете просто использовать название породы, чтобы получить набор черепах, содержащий все черепахи этой породы. Я не совсем уверен, что вы пытаетесь сделать, но я думаю, что вы, вероятно, хотите заменить:
set people-ahead min-one-of (other people in-cone (velocidad + espacio-personal + 0.5 ) 106.36 with [puesto? = false and target != any? filas]) [distance myself]
с
let candidates (filas in-cone (velocidad + espacio-personal + 0.5) 106.36 with [not puesto?])
set people-ahead min-one-of candidates [distance myself]