代码之家  ›  专栏  ›  技术社区  ›  Amber

如何在netlogo中更改圆心?

  •  0
  • Amber  · 技术社区  · 7 年前

    这次我正在努力改变netlogo中的圆心。 我尝试过使用布局圆并创建有序的海龟,但我无法让圆选择除中间坐标之外的其他坐标。

    to setup-food
      set-default-shape turtles "dot"
    
    repeat num-food
      [patch-at random-pxcor random-pycor [cro 10 [fd radius set color blue]]]
    
     ;that was my first attempt
     ;now for the second one  
    
    layout-circle turtles radius 
    repeat num-food 
    [ setxy random-pxcor random-pycor
      foreach range 25 [y -> ask turtle y
    [ foreach range (24 - y) [x -> create-link-with turtle (x + (1 + y))]]]
     ]
    end
    
    1 回复  |  直到 7 年前
        1
  •  3
  •   Bryan Head    7 年前

    具有 create-ordered-turtles ,您可以执行以下操作:

    to setup-food
      set-default-shape turtles "dot"
      repeat num-food [
        let center one-of patches
        cro 10 [
          move-to center
          fd radius
          set color blue
        ]
      ]
    end
    

    也就是说,你需要确保你把所有的海龟移到同一个地方。在您的代码中,它们在移动之前都会随机访问不同的补丁。

    推荐文章