Airplane seating

No preview image

1 collaborator

Default-person Amulya Angajala (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.0.2 • Viewed 697 times • Downloaded 35 times • Run 0 times
Download the 'Airplane seating' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


Info tab cannot be displayed because of an encoding error

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

globals
[
  seats
  aisle
  runway
]


patches-own [seat-type]
turtles-own [pref countdown seated chosen hasBag]

to setup
  clear-all
  resize-world -10 10 -100 10
  ask patches [ set pcolor grey]
  set seats patches with
  [pxcor <= 3 and pxcor >= -3 and pxcor != 0  and pycor >= 0]
  ask seats [set pcolor green]
  set aisle patches with
  [pxcor = 0 and pycor >= 0]
  ask aisle [set pcolor yellow]
   set runway patches with
  [pxcor = 0 and pycor < 0]
  ask runway [set pcolor black]
  ask seats [
    if pxcor = 3 [ set seat-type  "window"]
    if pxcor = 2 [ set seat-type  "middle"]
    if pxcor = 1 [ set seat-type  "aisle"]
    if pxcor = -1 [ set seat-type  "aisle"]
    if pxcor = -2 [ set seat-type  "middle"]
    if pxcor = -3 [ set seat-type  "window"]
  ]



  create-turtles numberPassengers
  [
    set color blue
    setxy 0 0
    move-to one-of runway
    set heading 0
    set countdown  2
    set hasBag random 100
    if (hasBag < bagPercent) [set countdown countdown + 10]
    set pref one-of (list "window" "aisle")
    set seated  0
    set chosen 0
    set shape "person"
  ]
  reset-ticks
end 

to move

  if heading = 0
  [ ifelse  ycor = 10
     [set heading 180]
  [

      ifelse count turtles-at 0 1 > 0 [
        ifelse ( ([heading] of one-of turtles-at 0 1) = 180)
        [set heading 180]

         [if not any? turtles-on patch-ahead 1 and seated = 0
         [fd 1]
       ]
     ]
   [
    if not any? turtles-on patch-ahead 1 and seated = 0
      [fd 1]
  ]
  ]]
  if heading = 180
  [
      ifelse  ycor = 0
      [set heading 0]

  [
      ifelse count turtles-at 0 -1 > 0 [
        ifelse ( ([heading] of one-of turtles-at 0 -1) = 0) ; or (([heading] of one-of turtles-at 0 -1) = 0 and ([heading] of one-of turtles-at 0 -2) = 0))
         [set heading 0]

         [if not any? turtles-on patch-ahead 1 and seated = 0
         [fd 1]
       ]
     ]
   [
    if not any? turtles-on patch-ahead 1 and seated = 0
      [fd 1]
  ]]]
end 

to go
  ; stop simulation if everyone is seated

  if not any? turtles with [seated = 0] [stop]
  ask turtles [
    seat-people
  ]
  ask seats [
    turn-patch-red
  ]
  tick
end 

;to go-once
;  ask turtles [
;    seat-people
;  ]
;  ask seats
;  [turn-patch-red]
;end

to-report try-seat [a b c]

  ifelse ([pcolor] of patch-at a 0 = green and


    ((pref = b and random count patches with [pycor = c and pcolor = green] > 1)

      or

      (random ((count patches with [pcolor = green] * 5)) ^ 3) <= 1))




    [
    set chosen a
    report true
  ]
  [report false]
end 

to seat-people
 if seated = 0 [
    ifelse chosen = 0 [

    ifelse (try-seat -1 "aisle" ycor)
    [][
      ifelse (try-seat 1 "aisle" ycor)
      [] [
        ifelse (try-seat 3 "window" ycor)
        [] [
          ifelse (try-seat -3 "window" ycor)
          [][
            ifelse (try-seat 2 "middle" ycor)
            [][
              ifelse (try-seat -2 "middle" ycor)
              [][move]
  ]]]]]]
    [
     ifelse countdown <= 0
      [move-to patch-at chosen 0
        set seated  1
      ]
      [set countdown countdown - 1
    ]]
  ]
end 
;   ifelse ([pcolor] of patch-at -1 0 = green and (pref = "aisle" or random count patches with [pcolor = green] <= 1))
;    [ifelse countdown <= 0
;      [move-to patch-at -1 0
;        set seated  1]
;      [set countdown countdown - 1]]
;    [move]
 ; ]

to turn-patch-red
  if one-of turtles-here != nobody [set pcolor  red]
end 



;([pxcor] of self = xcor) and ([pcolor] of self = green) and ([seat-type] of self = pref)

There are 2 versions of this model.

Uploaded by When Description Download
Amulya Angajala almost 7 years ago Fixed bug Download this version
Amulya Angajala almost 7 years ago Initial upload Download this version

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.