Bahria Cafe V2

Bahria Cafe V2 preview image

1 collaborator

Default-person sumbal khan (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by the author
Model was written in NetLogo 6.0.1 • Viewed 127 times • Downloaded 19 times • Run 0 times
Download the 'Bahria Cafe V2' 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

breed [persons person]
breed [waiters waiter]
breed [servers server]
persons-own[ time_to_leave wait-time]
patches-own[student-on-table]

globals [
  available
  tablem-x tablem-y
  tablef-x tablef-y
]

to setup
  clear-all
  open-door
  set-tables
  set-chairs
  set-reception
  student-come
  set-waiter
  set available 0
  reset-ticks
end 

to open-door
  ask patches with [ pxcor = 16 and pycor = 0]
  [
    set pcolor brown
  ]
end 

to set-waiter
  create-waiters 4 [
  set color white
  set shape "person"
  set size 1.8
  setxy random-xcor random-ycor
  ]
end 

to set-tables

  let table 1
  set tablem-x 8 + min-pxcor
  set tablem-y 7
  set tablef-x 24 + min-pxcor
  set tablef-y 7
  while [table < tables ]
  [
  ask patch tablem-x tablem-y [

      set pcolor brown
      set table table + 1
      set tablem-y tablem-y + 10
  ]


  ask patch tablef-x tablef-y [

      set pcolor brown
      set table table + 1
      set tablef-y tablef-y + 10
  ]
  ]
end 

to set-chairs

    ask patch 5 18[ set pcolor orange ]
    ask patch 5 16[ set pcolor orange ]
    ask patch 5 8[ set pcolor orange ]
    ask patch 5 6[ set pcolor orange ]

    ask patch 11 18[ set pcolor orange ]
    ask patch 11 16[ set pcolor orange ]
    ask patch 11 8[ set pcolor orange ]
    ask patch 11 6[ set pcolor orange ]

    ask patch 21 18[ set pcolor orange ]
    ask patch 21 16[ set pcolor orange ]
    ask patch 21 8[ set pcolor orange ]
    ask patch 21 6[ set pcolor orange ]

    ask patch 27 18[ set pcolor orange ]
    ask patch 27 16[ set pcolor orange ]
    ask patch 27 8[ set pcolor orange ]
    ask patch 27 6[ set pcolor orange ]
end 

to set-reception
  ask patch 10 32 [ set pcolor 65]
  ask patch 11 32 [ set pcolor 65]
  ask patch 12 32 [ set pcolor 65]
  ask patch 13 32 [ set pcolor 65]
  ask patch 14 32 [ set pcolor 65]
  ask patch 15 32 [ set pcolor 65]
  ask patch 16 32 [ set pcolor 65]
  ask patch 17 32 [ set pcolor 65]
  ask patch 18 32 [ set pcolor 65]
  ask patch 19 32 [ set pcolor 65]
  ask patch 20 32 [ set pcolor 65]
  ask patch 21 32 [ set pcolor 65]
  ask patch 22 32 [ set pcolor 65]
  ask patch 10 31 [ set pcolor 65]
  ask patch 11 31 [ set pcolor 65]
  ask patch 12 31 [ set pcolor 65]
  ask patch 13 31 [ set pcolor 65]
  ask patch 14 31 [ set pcolor 65]
  ask patch 15 31 [ set pcolor 65]
  ask patch 16 31 [ set pcolor 65]
  ask patch 17 31 [ set pcolor 65]
  ask patch 18 31 [ set pcolor 65]
  ask patch 19 31 [ set pcolor 65]
  ask patch 20 31 [ set pcolor 65]
  ask patch 21 31 [ set pcolor 65]
  ask patch 22 31 [ set pcolor 65]
  ask patch 10 30 [ set pcolor 65]
  ask patch 11 30 [ set pcolor 65]
  ask patch 12 30 [ set pcolor 65]
  ask patch 13 30 [ set pcolor 65]
  ask patch 14 30 [ set pcolor 65]
  ask patch 15 30 [ set pcolor 65]
  ask patch 16 30 [ set pcolor 65]
  ask patch 17 30 [ set pcolor 65]
  ask patch 18 30 [ set pcolor 65]
  ask patch 19 30 [ set pcolor 65]
  ask patch 20 30 [ set pcolor 65]
  ask patch 21 30 [ set pcolor 65]
  ask patch 22 30 [ set pcolor 65]

  create-servers 3 [
  set color yellow
  set shape "person"
  set size 2
  ]
  ask server 0 [setxy 12.5 31.5]
  ask server 1 [setxy 16 31.5]
  ask server 2 [setxy 20.5 31.5]
end 

to student-come

  Let m ( initial-students / 100 ) * 50
  create-persons m
  [
    ;choose-sex
    set color blue
    ;; become a man or a woman
    set size 1.5
    setxy 16 0.5
    set shape "person"
    set time_to_leave -1
    set wait-time -1
  ]
  Let fm initial-students - m
   create-persons fm
  [
    ;choose-sex
    set color pink
    ;; become a man or a woman
    set size 1.5
    setxy 16 0.5
    set shape "person"
    set time_to_leave -1
    set wait-time -1
  ]
end 

to go
   if not any? persons [
    stop
  ]
 ask persons[
   place-order
    ifelse wait-time > 0[
      set wait-time wait-time - 1
    ]
    [
   ifelse time_to_leave = -1  [
    moving-around
    direct-way
  ]
  [
      set time_to_leave time_to_leave - 1
    if time_to_leave = 0 [
      moving-around
        die
  ] ] ]]
  if count persons with [ycor > 0]  < initial-students
  [
  create-persons 1
  [
    choose-sex                   ;; become a man or a woman
    set size 1.5
    setxy 16 0.5
    set shape "person"
    set time_to_leave -1
    set wait-time -1
  ]
 ]
  tick
end 

to place-order

  if (wait-time < 0 )
  [
    if color = blue [
      move-to patch 12 29 ]
    if color = pink
    [
      move-to patch 19 29 ]

    set wait-time random Avg-time-on-counter
  ]
end 

to choose-sex  ;; turtle procedure
  set color one-of [pink blue]
end 

to moving-around
  if pcolor != white and pcolor != brown  and pcolor != red and ycor <= 29 [
  rt random-float 30
  lt random-float 30
  forward 1
  ]
   if ycor > 29
  [
    set ycor 20
  ]
  if pcolor = brown [
    fd 3
  ]
  if pcolor = orange [
    set pcolor white
   fd 0
  ask waiters [go-serve]
  set time_to_leave random Avg-waiting-time
  ]
  if pcolor = white and time_to_leave = 0 [
    set pcolor orange
  ]
end 

to go-serve
  ask waiters
  [
    if pcolor != brown and pcolor != red  [
  rt random-float 30
  lt random-float 30
  forward 1
  ]
    if pcolor = brown[
       set pcolor red
    ]
    if pcolor = red [
      set pcolor brown
    ]

  ]
end 

to direct-way
  if color = blue and xcor >= 16
  [
    rt 180
  ]
   if color = pink and xcor < 16
  [
    lt 180
  ]
end 

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

Attached files

File Type Description Last updated
Bahria Cafe V2.png preview Preview for 'Bahria Cafe V2' over 6 years ago, by sumbal khan Download

This model does not have any ancestors.

This model does not have any descendants.