海龟,补丁和它们从一个补丁顺序移动到下一个补丁

时间:2017-11-27 22:46:43

标签: netlogo

Platfrom:NetLogo

  • 问题

我想移动我的旗帜特定3点

  • A(-12 8)
  • B(-5 12)
  • C(6 4)

- 在此点旅行时,能量/时间随机减少。

- 到达C标志时将会死亡。

我之前问过,发现这个移动的解决方案。 (当乌龟达到2.点时它不会停止) - LINES1 -

breed [cities city]
breed [flag person]
flag-own [target]
to setup
  clear-all

  create-flag 1
  [ set size 6
    set shape "by"
    setxy -5 3
    set target patch -10 5
    face target
  ]

  < other commands >
end

to go
  ask flag-on patch -10 5
  [ set target patch <next place you want it to go>
    face target
  ]
  ask flag with [ shape = "by" ]
  [ forward 1 ]
end

人们建议使用此代码来保留任何目标。

    to go
      ask people [
        ;; if at target, choose a new random target
        if distance target = 0
          [ set target one-of houses
            face target ]
        ;; move towards target.  once the distance is less than 1,
        ;; use move-to to land exactly on the target.
        ifelse distance target < 1
          [ move-to target ]
          [ fd 1 ]
      ]
      tick
    end

在这段代码中,他们将随机旅行,我不想要这个。我不能在-LINES1-

实现这个部分

我试着用图片解释一下。 Main Idea

嗯,这就是问题:如何沿这些点移动乌龟并连接图表以获取能量/时间或能量/距离。

CC:@Seth Tisue @JenB @yacc

更新1

-Guys我完成了我的运动部分我的社区计划援助。在这段代码中,你的乌龟会移动特定的点,它会在到达最后一点时死亡。旅行时它正在绘制乌龟的数量

    breed [cities city]
    breed [flag person]
    flag-own [target]   ;;set features flag only


    to setup
     clear-all
     reset-ticks
     print "Setting up model."
     set-default-shape cities "house"  ;; set all cities shape by house

      create-flag 1
      [ 
        set SIZE 2
        set shape "turtle"
        setxy -11 13
        set target patch -3 12
        face target

      ]

     create-cities 1
        [set color yellow set SIZE 2 setxy 8 2]
    create-cities 1
        [ set color yellow set SIZE 2 setxy -3 12]
      create-cities 1
        [ set color yellow set SIZE 2 setxy 3 3]


    ask patch 3 3 [set pcolor red]
    end
    to go
      ask flag-on patch -3 12 [
        set target patch 8 2
        face target
      ]

      ask flag-on patch 8 2 [
       set target patch 3 3

        face target
      ]

      ask flag-on patch 3 3 [
       if distance target < 1    ;; check distance for last point
            [die]]




      ask flag with [ shape = "turtle" ]
      [fd 1]

 tick
end

0 个答案:

没有答案