Cafe_version2

No preview image

1 collaborator

Default-person Adeeba Mumtaz (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.2 • Viewed 49 times • Downloaded 4 times • Run 0 times
Download the 'Cafe_version2' 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
  set-tables
  set-chairs
  set-counter
  student-come
  set available 0
  reset-ticks
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 28[ set pcolor green ]
    ask patch 5 26[ set pcolor green ]
    ask patch 5 18[ set pcolor green ]
    ask patch 5 16[ set pcolor green ]
    ask patch 5 8[ set pcolor green ]
    ask patch 5 6[ set pcolor green ]
    ask patch 11 28[ set pcolor green ]
    ask patch 11 26[ set pcolor green ]
    ask patch 11 18[ set pcolor green ]
    ask patch 11 16[ set pcolor green ]
    ask patch 11 8[ set pcolor green ]
    ask patch 11 6[ set pcolor green ]
    ask patch 21 28[ set pcolor green ]
    ask patch 21 26[ set pcolor green ]
    ask patch 21 18[ set pcolor green ]
    ask patch 21 16[ set pcolor green ]
    ask patch 21 8[ set pcolor green ]
    ask patch 21 6[ set pcolor green ]
    ask patch 27 28[ set pcolor green ]
    ask patch 27 26[ set pcolor green ]
    ask patch 27 18[ set pcolor green ]
    ask patch 27 16[ set pcolor green ]
    ask patch 27 8[ set pcolor green ]
    ask patch 27 6[ set pcolor green ]
end 

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

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

to student-come
 create-persons N
  [
    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
  ]
end 

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

to go
   if not any? persons [stop]

  ask persons[
   order
    ifelse wait-time > 0[
      set wait-time wait-time - 1
    ]
    [
   ifelse time_to_leave = -1  [
    wiggle
    direct-way
  ]
  [

      set time_to_leave time_to_leave - 1
    if time_to_leave = 0 [
      wiggle
        die
  ] ] ]]
  if count persons with [ycor > 2]  < N
  [
  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 order

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

    set wait-time random Avg-Serving-time
  ]
end 

to wiggle
  if pcolor != white and pcolor != brown and ycor <= 30 [
  rt random-float 30
  lt random-float 30
  forward 1
  ]
  if ycor > 30
  [
    set ycor 20
  ]
  if pcolor = brown [
    fd 3
  ]
  if pcolor = green [
    set pcolor white
   fd 0
  set time_to_leave random Avg-waiting-time
  ]
  if pcolor = white and time_to_leave = 0 [
    set pcolor green
  ]
end 

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

;
;to seat-available?
;  ifelse color = blue and xcor >= 16 and patch-here = nobody [
;    set available 1]
;  [
;    set available 0]
;   ifelse color = pink and xcor < 16 and patch-here = nobody [
;    set available 1]
;  [
;    set available 0]
;
;end
;

There is only one version of this model, created 12 months ago by Adeeba Mumtaz.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.