乌龟在一条直线上穿过节点

时间:2015-10-21 15:55:25

标签: netlogo

我正在实施不同的步行程序。在其中一只海龟中,应该移动/走过"导航节点"按照最小努力原则(最短距离)直线朝向一组目标

我没有能够编程而没有得到奇怪的行走模式(here a netlogo file with a toy example)。关键程序是:

to-report route-on-the-way-to [l current-distance]
  let routes-on-the-way-to-one-goal (nodes in-radius 3 with [distance l < current-distance  - 1])
   report min-one-of routes-on-the-way-to-one-goal [distance self]
end

to walk-towards-goal
  let last-distance distance goal
  let best-route route-on-the-way-to goal last-distance

  ifelse best-route = nobody
  [ face goal ]
  [ face best-route]
  fd 1
end

to move-walkers

    if ( one-of (nodes-on patch-here) = goal and one-of (nodes-on patch-here) != myhome) [

      ifelse random-float 1.0 < 0.8
      [ set goal myhome
       walk-towards-goal ]

       [set goal one-of potential-goals
       walk-towards-goal ]

     ]  
    if (one-of (nodes-on patch-here) = goal and one-of (nodes-on patch-here) = myhome)
    [
      set goal one-of t-potential-goals
      walk-towards-goal ]

    if (nodes-on patch-here != goal)
    [ walk-towards-goal]

end

使用此解决方案,步行路线变化太大。有关如何做到这一点的想法,以便步行路线随着时间的推移更加一致吗?

0 个答案:

没有答案
相关问题