Student_Cafeteria_V3_Bahria

Student_Cafeteria_V3_Bahria preview image

1 collaborator

Default-person wasiq khan (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.3 • Viewed 97 times • Downloaded 12 times • Run 0 times
Download the 'Student_Cafeteria_V3_Bahria' modelDownload this modelEmbed this model

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


Comments and Questions

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

Click to Run Model

patches-own [
  table-number   ;; number (1, 2, or 3) to identify the food sources
]
globals[
  rtable-one
  rtable-two
  ltable-one
  ltable-two
  total-customer

]

turtles-own [fwd
  num
  i
  head
  ctimer
  servtime
]

breed [male maless]
breed [female femaless]
breed [waiter waiterss]

to setup
clear-all
    create-waiter 10
  [
    set shape "truck"
    set color green
    setxy -9 random-ycor

    set label "waiter"
     rt 60
     lt 60
  ]
  ask one-of waiter [setxy 9 random-ycor]
  ask one-of waiter [setxy 9 random-ycor]
  ask one-of waiter [setxy 9 random-ycor]
  create-female females
  [
     set shape "person"
    set color red
    setxy 2  -10
    set heading 0
    set fwd 1
  ]
  ;;students
  create-male males
  [
     set shape "person"
     set color blue
     set heading 0
     setxy -1 -10
     set fwd 1

  ]

  ask patches[
  creat-tables

  ]
  ask patches with [pxcor > -11 and pxcor < 11 and pycor > 11 and pycor <= 16] [set pcolor red]
  ask  turtles[
  set num 0
  set i 19
  set head 0
  set heading 0

  ]
  ask patch -5 14 [ set pcolor white
  ]
  ask patch -2.5 14 [ set pcolor white
  ]
  ask patch 2 14 [ set pcolor white
  ]

  reset-ticks
end 

to go

  check-customer
  ask turtles with [color = blue][

    ask one-of  turtles [

      ifelse (color = white)[eatattable]  [ifelse (color = pink)[ wait-atserving][fd 0.5]]
  if(pycor = -4 )[
      ifelse ( rtable-one != 1)[
         move-to patch -10 -3
        set color white
        set pcolor green + 1

         set rtable-one rtable-one + 1
        set ctimer wait-at-table
      ]


      [ if ( ltable-one != 1)[

        set ltable-one ltable-one + 1
         move-to patch 10 -3
         set pcolor red + 4
        set color white
        set ctimer wait-at-table

      ] ]

    ]


    ];;one of turtles

  ];;color blue
     ask turtles  with [color = red][

    ask one-of turtles with [color = red][
     if(pycor = 4 )[

        ifelse ( ltable-two != 1)[
          set ltable-two ltable-two + 1
          set color white
          move-to patch 10 5

          set pcolor green
          set ctimer wait-at-table
      ]

       [if (rtable-two != 1)[
        set color white
          move-to patch -10 5

          set pcolor red + 2
        set rtable-two rtable-two + 1
        set ctimer wait-at-table
      ]
      ]
    ]

    ]
    if (pcolor = red)[
    set color pink

    ]
    ask turtles with [color = pink]
    [
    move-to patch 2 12
     set servtime perc_boywaiting
    wait-atserving
    ]

  ]


  ask turtles[
   If (color = white)[eatattable]
    if (color = yellow)[move-to patch 0 -14
    ]

  ]

  ask  waiter [
  rt 45
    lt 45

  ]


  table-zero
  check-customer
  move-waiters
 tick

  if ticks >= 9000 [stop]
end 

to move-waiters
  ask turtles with [color = green]
  [
  if (pcolor != black )
    [
      if (sum [count turtles-here] of neighbors > 0)[
        set label "take order"]
    ]
    if (pcolor = red)
    [
      if (label = "take order")[
     set label "give-order"
      set heading 180
      ]
    ]
  ]
end 

to  check-customer
set total-customer females + males

  if (count turtles with [color = yellow] = total-customer)[
   STOP
  ]
end 

to table-zero
  ifelse any? turtles with [color = white] [ ][set rtable-two 0
  set ltable-two 0
  set rtable-one 0
  set ltable-one 0]
end 

to creat-tables ;; patch procedure

  if(pxcor > -9 and pycor > 12 and pxcor < 6 and pycor < 18) [set pcolor red]

  ;; setup Table one on the right

  if (distancexy (0.6 * max-pxcor) 4) < 0.6
  [ set table-number 3
   set pcolor blue
   set ltable-two 0
  ]

    if (distancexy (0.6 * max-pxcor) -4) < 0.6
  [ set table-number 1
  set pcolor gray
    set ltable-one 0
  ]



  if (distancexy (-0.6 * max-pxcor) 4) < 0.6
  [ set table-number 7
   set pcolor red
     set rtable-two 0
 ]

  if (distancexy (-0.6 * max-pxcor) -4) < 0.6
  [ set table-number 5
  set pcolor green
    set rtable-one 0
  ]
end 

to eatattable
  set ctimer ctimer - 1   ;decrement-timer
  set label ctimer
  if ctimer = 0
    [
      set label ""
      set pcolor black
      move-home
    ]
end 

to wait-atserving
  set servtime servtime - 1   ;decrement-timer

  set label "waiting"
  if servtime = 0
    [
      set color red
      set label "order_Received"
      set heading 180
    ]
end 


 To move-home

  fd 6
  set color yellow
  move-to patch 0 -14
end 

There is only one version of this model, created almost 6 years ago by wasiq khan.

Attached files

File Type Description Last updated
Student_Cafeteria_V3_Bahria.png preview Preview for 'Student_Cafeteria_V3_Bahria' almost 6 years ago, by wasiq khan Download

This model does not have any ancestors.

This model does not have any descendants.