Student_Cafeteria_V1_Bahria

Student_Cafeteria_V1_Bahria preview image

1 collaborator

Default-person wasiq khan (Author)

Tags

cosmos 

Tagged by wasiq khan almost 6 years ago

Visible to everyone | Changeable by the author
Model was written in NetLogo 6.0.3 • Viewed 121 times • Downloaded 8 times • Run 0 times
Download the 'Student_Cafeteria_V1_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
]

breed [male maless]
breed [female femaless]

to setup
clear-all
  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  turtles[
  set num 0
  set i 19
  set head 0
  set heading 0

  ]
  reset-ticks
end 

to go

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

    ask one-of turtles[

      ifelse (color = white)[eatattable]  [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
      ]
      ]
    ]

    ]

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

  ]



  table-zero
  check-customer
 tick

  if ticks >= 9000 [stop]
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 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_V1_Bahria.png preview Preview for 'Student_Cafeteria_V1_Bahria' almost 6 years ago, by wasiq khan Download

This model does not have any ancestors.

This model does not have any descendants.