【问题标题】:NetLogo Battle Simulation: Placing soldiers in between specific coordinates?NetLogo 战斗模拟:在特定坐标之间放置士兵?
【发布时间】:2019-12-02 19:32:00
【问题描述】:

我是 NetLogo 的新手,我不确定如何将 300 名斯巴达人排成一排。假设一个 2x5 块的区域,海龟相互重叠。我尝试过使用新芽,这达到了特定的坐标要求,但是每个补丁只有一个海龟。这是我的一些代码。

    ask patches with [pxcor > 0 and pycor > -2 and pycor < 2]
    [ sprout 1 [ set color red ] ]

 or

    to setup-spartans
    create-spartans 300
    set-default-shape turtles "person"

    ask spartans
   [ setxy random-xcor -3  ;; makes only a single row and goes across entire screen  
                           ;; (I need it to be in a specific area)
     set heading 180
     set color red ]

    end

【问题讨论】:

    标签: netlogo


    【解决方案1】:

    这样的事情怎么样?

    create-spartans 300 [
      set xcor -2 + random-float 5
      set ycor -1 + random-float 2
    ]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多