Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- to move
- ; select customers that need to move: those who did not decide to balk and are still not at the checkout counter
- ; they might have just arrived, or are already in queue (if the queue moves, they need to move)
- ask customers with [(status = "arrived") or (status = "atqueue")] [
- ; face left
- ask customers with [turned = 0] [set heading 90]
- ask customers with [queue_nr = 0 and turned = 0] [
- if [pcolor] of patch-ahead (140 - c0_x) = black [
- set heading 0
- set turned 1
- ]
- ]
- ask customers with [queue_nr = 1 and turned = 0] [
- if [pcolor] of patch-ahead (140 - c1_x) = black [
- set heading 0
- set turned 1
- ]
- ]
- ask customers with [queue_nr = 2 and turned = 0] [
- if [pcolor] of patch-ahead (140 - c2_x) = black [
- set heading 0
- set turned 1
- ]
- ]
- ; there's someone in front of me? in at leash 25px distance?
- let i 1
- let min_dist 25
- let num_ahead 0
- while [i < min_dist] [
- if (any? turtles-on patch-ahead i) [ set num_ahead num_ahead + 1 ]
- set i i + 1
- ]
- ; if there's someone in front of me, i'm at the queue
- if (num_ahead > 0) and (status = "arrived") [
- set status "atqueue"
- ; mark the time I entered the queue
- set entered_queue ticks
- ]
- ; if i'm still not at the checkout counter and there's no one in front of me, keep walking!
- if (num_ahead = 0) [
- ifelse Scenario = "two-counters" [
- if (queue_nr = 1) and (distancexy c1_x c1_y > 5) [ fd 1 ]
- if (queue_nr = 2) and (distancexy c2_x c2_y > 5) [ fd 1 ]
- ]
- [
- if (distancexy c0_x c0_y > 5) [ fd 1 ]
- ]
- ]
- ]
- ; customers that know the app go straight to "waiting area", because they've already pre ordered
- if scenario = "app" [
- ask customers with [app_info = 1 and (status = "arrived" or status = "atqueue")] [
- set status "ordered_w_app"
- set color turquoise
- let target one-of patches with [(pcolor = white) and (not any? turtles-here)]
- face target
- while [patch-here != target] [
- forward 1
- ]
- ; for how long will I wait?
- set wt times "waiting_time"
- set ref_wt ticks
- set death_time ref_wt + wt
- set entered_waiting ticks
- ; app user contacts someone at the queue to tell about the app
- if (any? customers with [status = "atqueue" and not any? link-neighbors]) [
- create-link-with one-of customers with [status = "atqueue" and not any? link-neighbors] [
- set visited 0
- ]
- ]
- ]
- ; with a 50% chance, customer accepts suggestion and pre-order through through app
- ; color turns green and he goes straight to waiting area
- ask links with [visited = 0] [
- set wt times "waiting_time"
- set visited 1
- let my_nodes both-ends
- let new_user one-of my_nodes with [ color != turquoise ]
- ifelse random 100 < 50 [
- ask new_user [
- set app_info 1
- set color turquoise
- set app_adopters app_adopters + 1
- ]
- ] [ die ]
- ]
- ]
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement