【问题标题】:Turtles moving into a circular formation海龟进入圆形阵型
【发布时间】:2014-11-08 05:26:57
【问题描述】:

我有两个品种的 turtle(A)turtle(B)

  • Turtle(A) 在世界各地随机移动。

  • turtle(A) 遇到turtle(B) 时,我希望turtle(B) 移动到围绕坐标的半径内,从而希望形成一个圆。

任何帮助/提示?

【问题讨论】:

    标签: geometry netlogo turtle-graphics


    【解决方案1】:

    该规范有点不完整,但这可能会让您入门:

    globals [lst]
    breed [taggers tagger]
    breed [taggeds tagged]
    taggeds-own [caught?]
    
    
    to setup
      ca
      set lst []
      ask n-of 50 patches [sprout-taggeds 1 [set caught? false]]
      ask n-of 5 patches [sprout-taggers 1]
    end
    
    to move ;;turtle proc
      ask taggeds [
        if not caught? [
          move-to one-of neighbors
          ]
      ]
    end
    
    to tag ;;tagger proc
      let candidates taggeds-on neighbors
      if any? candidates [
        let captured one-of candidates
        ask captured [set caught? true]
        set lst lput captured lst
      ]
    end
    
    to go
      ask turtles [move]
      ask taggers [tag]
      layout-circle lst 5  ;;aribtary radius of 5
    end
    

    【讨论】:

    • 这太好了,谢谢。我想知道是否有办法让圆圈不在世界的中心,即不使用“layout-circle”命令。
    • 当然,你可以把一个圆分成多少个部分,就像你有海龟要布局一样,把中心放在你想要的任何地方,选择一个半径,然后通过你的海龟列表在每个圆坐标上放置一个.
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-30
    • 2012-05-17
    • 1970-01-01
    • 2014-03-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多