Имитировать движение дороги с NetLogo "место автомобиля" не работает, что не так? - PullRequest
0 голосов
/ 30 марта 2019

После создания среды NetLogo на изображении вниз посмотрите, я создаю код "место автомобиля", но не нашел автомобили этот код не работает! смотри код:

to place-cars

  ;make a random placement of cars
  ask n-of (num-of-cars / 5) patches with [meaning = "road-up"] [
    if not any? cars-on patch pxcor (pycor + 1) and not any? cars-here and not any? cars-on patch pxcor (pycor - 1) and not any? patches with [meaning = "crossing"] in-radius 2 [
      sprout-cars 1 [
        set size 2
        set will-turn? "maybe"
        set will-stop? "maybe"
        set shape "car top"
        set heading 0
        let s random 10
        if s < 7 [set maxSpeed speed-limit - 15 + random 16]
        if s = 7 [set maxSpeed speed-limit - 20 + random 6]
        if s > 7 [set maxSpeed speed-limit + random 16]
        set speed maxSpeed - random 20
      ]
    ]
  ]

  ask n-of (num-of-cars / 3) patches with [meaning = "road-down" and count turtles-on neighbors = 0] [
    if not any? cars-on patch pxcor (pycor + 1) and not any? cars-here and not any? cars-on patch pxcor (pycor - 1) and not any? patches with [meaning = "crossing"] in-radius 2 [
      sprout-cars 1 [
        set size 2
        set shape "car top"
        set politeness basic-politeness + random (101 - basic-politeness)
        if random 100 > basic-politeness [set politeness random 21]
        set heading 180
        set will-turn? "maybe"
        set will-stop? "maybe"
        let s random 10
        if s < 7 [set maxSpeed speed-limit - 15 + random 16]
        if s = 7 [set maxSpeed speed-limit - 20 + random 6]
        if s > 7 [set maxSpeed speed-limit + random 16]
        set speed maxSpeed - random 20
      ]
    ]
  ]

  ask n-of (num-of-cars / 3) patches with [meaning = "road-left" and count turtles-on neighbors = 0] [
    if not any? cars-on patch (pxcor + 1) pycor and not any? cars-here and not any? cars-on patch (pxcor - 1) pycor and not any? patches with [meaning = "crossing"] in-radius 2 [
      sprout-cars 1 [
        set will-turn? "maybe"
        set will-stop? "maybe"
        set size 2
        set shape "car top"
        set heading 270
        let s random 10
        if s < 7 [set maxSpeed speed-limit - 15 + random 16]
        if s = 7 [set maxSpeed speed-limit - 20 + random 6]
        if s > 7 [set maxSpeed speed-limit + random 16]
        set speed maxSpeed - random 20
      ]
    ]
  ]

  while [count cars < num-of-cars] [
    ask one-of patches with [meaning = "road-right"] [
      if not any? cars-on patch (pxcor + 1) pycor and not any? cars-here and not any? cars-on patch (pxcor - 1) pycor and not any? patches with [meaning = "crossing"] in-radius 2 [
        sprout-cars 1 [
          set will-turn? "maybe"
          set will-stop? "maybe"
          set size 2
          set shape "car top"

          set heading 90
          let s random 10
          if s < 7 [set maxSpeed speed-limit - 15 + random 16]
          if s = 7 [set maxSpeed speed-limit - 20 + random 6]
          if s > 7 [set maxSpeed speed-limit + random 16]
          set speed maxSpeed - random 20
        ]
      ]
    ]
  ]

end
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...