netlogo - 如何使海龟根据彼此之间不同的间隔间隔表现出不同的行为?
问题描述
我正在尝试开发一个模型来模拟航站楼区域的空中交通流量。由于之前大家的帮助,我已经取得了一些进展。现在我想让每架飞机之间保持适当的间隔。随着间隔减小,飞机将被要求首先减速以保持间隔。当彼此之间的间隔太小时,将要求飞机引导离开,直到该区域被清除。根据我目前的进展,飞机能够适当减速以保持分离,但是,它们不能被引导出去。
在代码中,我要求飞行器在间距小于 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
我要求飞机继续向外移动,直到他周围没有飞机。
解决方案
推荐阅读
- javascript - 我需要将两个日期分成不同的值
- php - 如何根据选定的值插入多行但在另一个变量上没有相应的值大小
- c# - 使用 c# 通过 api 在 Azure datalake 中上传文件
- ios - Nativescript ActionBar 溢出到 iPhone 11 模拟器上的安全区域(缺口)
- python - Python:如何从字典列表中创建 csv 字符串(无文件)?
- xml - 在 xslt 中的“format-number()”中使用“current()”向左填充
- c# - 如何使用 lambda 表达式从列表中获取继承的对象成员
- git - 如何为具有私有 git 子模块的私有仓库设置 GitHub Actions CI 服务?
- variables - 并行 Jenkinsfile 任务中的局部变量
- reactjs - 如果组件中不存在 redux 存储中的值,则重定向用户