Lois
Lois

Reputation: 1

Minimum distance and interference between turtles

I am doing boarding processes model with anti-Covid measures. I would like to know if any of you could help me.

I don't know how to insert this in my code:

to go
  ; stop when all the pessengers have found a seat
  if not any? turtles with [seated? = false]
    [stop]

 set counter counter + 1

   (foreach (sort turtles with [seated? = false] ) [a ->
      ask a [

      ; check if we have reached the correct row of seats

      ifelse [seat-row] of patch-at 1 -1 = assigned-seat-row
      [
        ; only seat the passenger if he/she has stored the luggage OR if we don't take luggages into account
        ifelse luggage-store-ticks = 0 or storing-luggage-takes-time = false
        [
          let seat patch-at 1 -1

          set xcor [pxcor] of seat
          set ycor assigned-seat-number
          set seated? true
        ]
        [
          set luggage-store-ticks luggage-store-ticks - 1
        ]
      ]
      [
        let passenger-ahead one-of turtles-on patch-ahead 1
        ifelse passenger-ahead != nobody
        [
          set speed [speed] of passenger-ahead

          if xcor != airplane-door-x-cor
          [fd speed]
        ]
        [
          set speed default-speed
          fd speed
        ]
      ]
    ]
  ])

end 

Upvotes: 0

Views: 97

Answers (1)

JenB
JenB

Reputation: 17678

You could extend your existing patch-ahead 1 to also look at the patches 2, 3 and 4 ahead. But I think it would be easiest to use in-cone 5 10 or similar. That will look ahead in a cone shape, 10 degrees on either side of the heading and a distance of 5. So you could do something like:

let potential-blockers turtles in-cone 5 10
let blocker min-one-of potential-blockers [distance myself]

That should (not tested) find the closest turtle approximately in front and name it "blocker" so that you can do things like check if it's far enough away, match speed (see the basic traffic model in the NetLogo models library)

Upvotes: 1

Related Questions