驾驶模拟:超车,我在netlogo中有车道变换的问题

时间:2018-02-21 17:04:51

标签: netlogo

在我的项目中,我正在编写一个半自动汽车模拟,作为一个初学者,我使用了驾驶模拟的基本版本,并旨在扩展它,惠斯特扩大编码,我试图模仿车道居中,所以已经做了每条车道或一条路三层厚,这样做我现在正努力使汽车正常超车。

确定汽车应该占据所有三个补丁而不是在一条车道上有两辆汽车,但在编码时,现在应该超车的内车道上的汽车将只留下来。我希望内线超车。

to control-speed01
let in-lane (patch-set patch-ahead 3 patch-left-and-ahead 26 2 patch-right-
and-ahead 26 2 )
let car-ahead one-of cars-on in-lane

 ifelse car-ahead = nobody  [
ifelse speed < maxSpeed [set speed speed + acceleration] [set speed speed - 
deceleration]
 ]
 [
ifelse [speed] of car-ahead = 0 [set speed 0] [
  ifelse [speed] of car-ahead >= maxSpeed [
    set speed maxSpeed
    set speed speed - deceleration
  ] [
 ; try to overtake
  ifelse [meaning] of patch-left-and-ahead 26 2 = meaning and not any? 
turtles-on patch-left-and-ahead 26 2 and [meaning] of patch-left-and-ahead 90 1 != "crossroad"
  and meaning != "crossing" and [meaning] of patch-left-and-ahead 180 1.3 != "crossing" and not any? turtles-on patch-left-and-ahead 169 3
  and not any? turtles-on patch-left-and-ahead 45 1 and not any? turtles-on patch-left-and-ahead 135 1 and not any? turtles-on patch-left-and-ahead 23 2
  and not any? turtles-on patch-left-and-ahead 157 2 and not any? turtles-on patch-left-and-ahead 12 3 and [meaning] of patch-ahead 1 != "crossing" [move-to patch-left-and-ahead 90 1] [


    ifelse [meaning] of patch-right-and-ahead 90 1 = meaning and not any? turtles-on patch-right-and-ahead 90 14 and [meaning] of patch-right-and-ahead 90 1 != "crossroad"
    and meaning != "crossing" and [meaning] of patch-right-and-ahead 180 1.3 != "crossing" and not any? turtles-on patch-right-and-ahead 12 3
    and not any? turtles-on patch-right-and-ahead 45 1 and not any? turtles-on patch-right-and-ahead 135 1 and not any? turtles-on patch-right-and-ahead 23 2
    and not any? turtles-on patch-right-and-ahead 157 2 and not any? turtles-on patch-right-and-ahead 169 3 and [meaning] of patch-ahead 1 != "crossing"[move-to patch-right-and-ahead 90 1] [
      set speed [speed] of car-ahead
      set speed speed - deceleration]
  ][enter image description here][1]
  ]
 ]
 ]
 end

在编码中是一个关于处理行人过路处的部分,但为了简单起见,我暂时已将人员移除。

我认为我需要在“试图超车”的第一行中有不同的角度。但我不确定。我强调我是初学者,如果我能让问题更清楚,请说。

0 个答案:

没有答案