如何让海龟以特定颜色吸引?

How to make Turtles attract with a specific color?

我在玩 Netlogo,我已经为两个不同的组分配了至少两种颜色。这两组代表了两种不同的刻板印象——以蓝色和红色为代表。

我的目标是: 我需要一个 'RED' 来与所有其他红色一起聚集,而蓝色与所有其他蓝色一起聚集。

这是我当前的代码。

breed [ firstgroups firstgroup ]
breed [ secondgroups secondgroup ]

turtles-own[
  groupmates 
  nearest-neighbor
]

to setup
  clear-all
  crt population-blue
  [ set size 1.5
    set shape "person"
    setxy random-xcor random-ycor 
    set color blue
   ]
  crt population-green
  [ set size 1.5
    set shape "person"
    setxy random-xcor random-ycor 
    set color green
   ]
  reset-ticks
end

to go
  ;;ask turtles [ group ]
  ask turtles [ fd 1 ]
  tick
end

;;to group
;;  ifelse (
turtles-own[
  groupmates ; unused
  nearest-neighbor
]

to setup
  clear-all
  setup-globals
  create-firstgroups population-blue ;use your breeds
  [ set size 1.5
    ;set shape "person"
    setxy random-xcor random-ycor 
    set color blue
   ]
  create-secondgroups population-green
  [ set size 1.5
    ;set shape "person"
    setxy random-xcor random-ycor 
    set color green
   ]
  reset-ticks
end

to go
  ask turtles [ group ] ;use `group`
  ask turtles [ fd 1 ]
  tick
end

to group ;turtle proc
  ;let _partner min-one-of other breed [distance myself] ;form subgroups
  let _partner one-of other breed ;form big gropus
  set heading mean-heading (list heading towards _partner)
end

to-report mean-heading [ headings ] ;by Bryan Head
  let mean-x mean map sin headings
  let mean-y mean map cos headings
  report atan mean-x mean-y
end