Netlogo发芽海龟的间距小于一个补丁 [英] Netlogo Sprouting turtles spaced at less than one patch

查看:128
本文介绍了Netlogo发芽海龟的间距小于一个补丁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将乌龟放在每个黑色补丁上(如下图所示),以使乌龟之间完全没有缝隙:

I want to place turtles on each of the black patches(below Figure) such that there is no gap between turtles at all:

我现在使用的代码:

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

这将产生以下结果:

但是我也想在两个补丁之间放置海龟.这样我就可以遮盖住显示的黑色部分.

But I want to place turtles in between each of the two patches as well. So that I can cover the showing black part.

注意:改变乌龟的形状对我来说没有用,尽管它会覆盖黑色区域.我的目标是从这些特工创建一个恢复力场,它们之间的间隙是特工可能从中逃脱的环孔.[有点类似于特工弹回墙壁上.]

Note: Changing the shape of turtles is no use to my purpose though it would cover the black area. My aim to create a replusion force field from these agents and gaps in between are loop holes from where agents may escape.[Somewhat similar to agents bouncing back on a wall].

推荐答案

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

Here is a fun solution:

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

我并不是说这是唯一可能的解决方案,但是它很简单,并且可以工作. (不过,我认为情况是必须关闭世界包装.)

I'm not saying that it is the only possible solution, but it's simple enough, and it works. (World wrapping has to be turned off, though, which I assume is the case.)

这篇关于Netlogo发芽海龟的间距小于一个补丁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆