Simulate traffic in carousels

I write algorithms for red cars, turning right with a direction from the right to the disc (heading = 90) in the direction of heading = 180. but turn his car right, go too. as it came to a certain extent, he first turned the corner to go to heading 180

image

Have I tried the code without the correct result? [

 ifelse heading = 90 
  [
    if distancexy 0 0 < 30
    [
      rt 22
      fd speed
      if xcor = -2
      [
        set heading 180
        fd speed
      ]
    ]

  ]
  [
    fd speed
  ]

Or am I writing such code?

ifelse heading = 90 
  [
    if distancexy 0 0 < 30
    [
      rt 22
      fd speed
      if ycor = -30
      [
        set heading 180
        fd speed
      ]
    ]

  ]
  [
    fd speed
  ]
+4
source share
1 answer

You use exact conditions, such as xcor = -2and ycor = -30, but these conditions are probably never true.

NetLogo turtles do not move smoothly. They jump from point to point. Imagine a turtle disappearing from an old place and reappearing in a new place. The turtle does not go through all the points between them.

, , xcor -2,2 . fd 1, xcor -1.2. , , xcor = -2, . xcor -2. -2,2. -1.2. xcor = -2 .

, xcor = -2, , , , pxcor = -2 (true ) xcor > -3 and xcor < -2 - .

JenB fooobar.com/questions/1621301/.... . , .

+1

Source: https://habr.com/ru/post/1621299/


All Articles