带有NetLogo的代理着色

带有NetLogo的代理着色,netlogo,Netlogo,我正试图在一个带有NetLogo的移动公告板上模拟公告的颜色。我可以让公告在它们相遇时改变它们的颜色,但是颜色的改变是随机的,有时具有相同颜色的公告在我的半径内接触或靠近。我希望公告在给定的RADUI中具有唯一的颜色。这是我代码的一小部分。有人能帮我吗 to color-bulletins ask bulletins [ ask other bulletins in-radius 2[ ask one-of bulletins [ set color green]

我正试图在一个带有NetLogo的移动公告板上模拟公告的颜色。我可以让公告在它们相遇时改变它们的颜色,但是颜色的改变是随机的,有时具有相同颜色的公告在我的半径内接触或靠近。我希望公告在给定的RADUI中具有唯一的颜色。这是我代码的一小部分。有人能帮我吗

to color-bulletins
  ask bulletins [
   ask other bulletins in-radius 2[ 
      ask one-of bulletins [ set color green] 
      ask one-of bulletins [ set color white ]
      ask one-of bulletins [ set color yellow]
      ask one-of bulletins [ set color blue ]
  ]]
end

以下是一种方法:

breed [ bulletins bulletin ]

to setup
  ca
  create-bulletins 1000 [ setxy random-xcor random-ycor ]
end

to color-bulletins
  ask bulletins [
    let used-colors [ color ] of other bulletins in-radius 2
    let available-colors filter [ not member? ? used-colors ] base-colors
    set color ifelse-value (length available-colors > 0)
      [ one-of available-colors ]
      [ one-of base-colors ]
  ]
end
这假设您只想使用,并且它们都可以被使用,在这种情况下,您仍然会遇到“颜色冲突”,但对此您无能为力。除非您的代理的空间分布相当密集、困难,否则这种情况不应该经常发生