Netlogo Sprouting海龟间隔小于一个补丁

时间:2014-08-09 17:04:36

标签: netlogo

我想把乌龟放在每个黑色斑块上(图下方),这样海龟之间就没有间隙了:

enter image description here

我现在使用的代码:

ask patches with [pcolor = black][sprout-dead-turtles wall-agents [set color red]]

这给出了以下结果:

enter image description here

但是我也希望将两只斑块放在两只斑块之间。所以我可以覆盖显示黑色部分。

注意:改变海龟的形状对我的目的没用,虽然它会覆盖黑色区域。我的目标是从这些代理中创建一个复制力场,并在它们之间留有间隙,这些是代理可能逃脱的环洞。[有点类似于在墙上弹回的代理]。

1 个答案:

答案 0 :(得分:1)

这是一个有趣的解决方案:

breed [ dead-turtles dead-turtle ]

to setup
  ca  
  ; draw the background:
  ask patches with [ abs pxcor != max-pxcor and abs pycor != max-pycor ] [ set pcolor grey ]
  ask patches with [ pycor = max-pycor and abs pxcor <= 1 ] [ set pcolor white ]
  set-default-shape dead-turtles "circle"

  ; sprout a first set of turtles:
  ask patches with [ pcolor = black ] [
    sprout-dead-turtles 1 [ set color red ]
  ]

  ; create temporary links between these, and use the
  ; links to place a new set of turtles in between:
  ask dead-turtles [
    create-links-with turtles-on neighbors4 
  ]
  ask links [
    let target end2
    ask end1 [
      hatch 1 [
        face target
        fd distance target / 2
      ]
    ]
    die ; remove the link
  ]
end

我并不是说这是唯一可行的解​​决方案,但它很简单,而且很有效。 (但是,世界包装必须关闭,我认为是这种情况。)