首页 > 解决方案 > 如何使海龟根据彼此之间不同的间隔间隔表现出不同的行为?

问题描述

我正在尝试开发一个模型来模拟航站楼区域的空中交通流量。由于之前大家的帮助,我已经取得了一些进展。现在我想让每架飞机之间保持适当的间隔。随着间隔减小,飞机将被要求首先减速以保持间隔。当彼此之间的间隔太小时,将要求飞机引导离开,直到该区域被清除。根据我目前的进展,飞机能够适当减速以保持分离,但是,它们不能被引导出去。

在代码中,我要求飞行器在间距小于 0.5 时转向并变红。而当他周围没有飞机时(半径1.5),飞机会折返。现在飞机可以变成红色,但没有任何动作可以朝着我指定的方向前进。我怀疑我没有正确设置局部运动,所以程序将“着陆程序”和“冲突解决绕道”混合在一起。有什么建议可以解决这个问题吗?或者更好的方式来实现这个功能?期待一些有见地的答复。

to go 
 ask aircrafts [let blocking-aircrafts other aircrafts in-cone 1 270
 let blocking-aircraft min-one-of blocking-aircrafts [ distance myself ]
 ask aircrafts [ifelse blocking-aircraft != nobody [ conflict-resolution ] [landing-procedure]]]
end 

我要求系统根据分离定义首先使用哪个程序。

to landing-procedure
ask aircrafts
[if route02? [face star 2 fd airspeed ]]
end

我设置 route02 来定义飞机如何在常规飞行路径上移动。

to conflict-resolution
conflict-resolution-detour
conflict-resolution-deceleration
end

to conflict-resolution-deceleration
let blocking-aircrafts other aircrafts in-cone 1.2 180
let blocking-aircraft min-one-of blocking-aircrafts [ distance myself ]
ask aircrafts-here  [if blocking-aircraft != nobody 
[ if route02? [fd airspeed - 0.000000075 if airspeed = [airspeed] of blocking-aircraft [set airspeed [airspeed] of blocking-aircraft]]]]
end

to conflict-resolution-detour
let blocking-aircrafts other aircrafts in-cone 0.5 180
let blocking-aircraft min-one-of blocking-aircrafts [ distance myself ]
let truningback-ornots other aircrafts in-radius 1.2
let truningback-ornot min-one-of truningback-ornots [ distance myself ]
ask aircrafts-here [ if blocking-aircraft != nobody
[ if route02? [ ifelse truningback-ornot != nobody [set heading 45 fd airspeed set color red] [set heading 315 fd airspeed set color black ]]]]
end

我要求飞机继续向外移动,直到他周围没有飞机。

标签: netlogo

解决方案


推荐阅读