globals [ this-seed decision-rule-num ERROR_OCCURRED ERROR_COUNT ERROR_PRODUCER ny delta last-change last-conflict changes conflicts arrivals-at-home arrivals-at-work witness sqrt-2 sqrt-3 ] breed [ cars car ] cars-own [ possible-patches list-of-possible-patches selected-patch xhome yhome xwork ywork myhome mywork at-home? at-work? at-home-since at-work-since just-left? from-work? from-home? moves-after-return lane type-of-current-position turn-after-go trajectory cars-opposite memory perception strength ] patches-own [ occupied? allowable? tenants-here workers-here distance-to-current-occupier's-workplace ] to setup clear-all clear-output reset-ticks set last-change 0 if behaviorspace-run-number > 0 [ set decision-rule-num behaviorspace-run-number mod 3 set kappa 0 ifelse decision-rule-num = 0 [ set decision-rule "ISING" set kappa ( random 20 + 5 ) / 10 ] [ ifelse decision-rule-num = 1 [ set decision-rule "LOCAL MAJORITY" ] [ ifelse decision-rule-num = 2 [ set decision-rule "NORM EQ" ] [ ifelse decision-rule-num = 3 [ set decision-rule "NORM HI" ] [ set decision-rule "UNDEFINED" ] ] ] ] set locality random 30 + 20 set commuting-distance random 30 + 20 ] ifelse randomise? [ set this-seed new-seed ] [ set this-seed 3718 ] random-seed this-seed set ERROR_OCCURRED false set ERROR_COUNT 0 set ERROR_PRODUCER -1 set sqrt-2 sqrt 2 set sqrt-3 sqrt 3 set witness 99 set ny 0.1 set delta 0 ask patches [ set occupied? false set pcolor black set workers-here turtle-set nobody set tenants-here turtle-set nobody ] ask patches with [ pycor = 33 or pycor = -33 or pycor = 34 or pycor = -34 or pycor = 0 or pycor = -1 ] [ set pcolor 5 ] ask patches with [ pxcor = 33 or pxcor = -33 or pxcor = 34 or pxcor = -34 or pxcor = 0 or pxcor = -1 ] [ set pcolor 5 ] ask n-of initial-cars patches with [ pcolor = 5 and count neighbors with [ pcolor = black ] = 3 ] [ sprout-cars 1 [ set color blue set shape "arrow" set xhome xcor set yhome ycor set xwork work-home-distance xcor set ywork work-home-distance ycor determine-direction set cars-opposite turtle-set nobody set trajectory ( list ( list xcor ycor lane "undefined" heading) ) set memory ( list ( list self self ticks lane true 1 ) ) ] let this-car one-of cars-here let this-cars-home one-of neighbors4 with [ pcolor = black or pcolor = brown or pcolor = violet ] ask this-cars-home [ if pcolor = black [ set pcolor brown ] set tenants-here ( turtle-set tenants-here this-car ) ] let parking-lot self ask patch-at [ xwork ] of this-car [ ywork ] of this-car [ let work-address min-one-of ( patches with [ pcolor = 5 ] ) [ distance myself ] ask work-address [ set parking-lot one-of neighbors with [ pcolor = black or pcolor = violet or pcolor = brown and count neighbors with [ pcolor = 5 ] = 3 ] let alternative-parking-lots patches with [ pcolor = black or pcolor = violet or pcolor = brown and count neighbors with [ pcolor = 5 ] = 3 ] if parking-lot = nobody [ set parking-lot min-one-of alternative-parking-lots [ distance myself ] ] ] ask parking-lot [ set pcolor violet set workers-here ( turtle-set workers-here this-car ) ] ] ask this-car [ set xwork [ pxcor ] of parking-lot set ywork [ pycor ] of parking-lot set myhome this-cars-home set mywork parking-lot set just-left? true set at-work? false set at-home? false set from-home? true set from-work? false set at-home-since 999999 set at-work-since 999999 set moves-after-return 0 ask patch-here [ set occupied? true ] ] ;; set occupied? true ] end to determine-direction let side neighbors with [ pcolor != 5 ] if count side = 3 [ ;; between crossroads ifelse max [ pycor ] of side = min [ pycor ] of side [ if max [ pxcor ] of side > xcor [ set lane "left" ] set heading 90 if random 2 = 0 [ set heading 270 ] ] [ set heading 0 if random 2 = 0 [ set heading 180 ] ] ifelse [ pcolor ] of patch-right-and-ahead 90 1 != 5 [ set color green set lane "right" ] [ set color red set lane "left" ] ] check-direction "determine-direction" end to check-direction [ caller ] let side neighbors with [ pcolor != 5 ] if count side = 3 ;; between crossroads [ if lane = "left" and [ pcolor ] of patch-left-and-ahead 90 1 = 5 [ show ( word caller " ERROR: left-driver on wrong lane" ) set ERROR_COUNT ERROR_COUNT + 1 if ERROR_PRODUCER < 0 [ set ERROR_PRODUCER who ] ;; change-lane ;; show (word caller " ERROR corrected" ) ] if lane = "right" and [ pcolor ] of patch-right-and-ahead 90 1 = 5 [ show ( word caller " ERROR: right-driver on wrong lane" ) set ERROR_COUNT ERROR_COUNT + 1 if ERROR_PRODUCER < 0 [ set ERROR_PRODUCER who ] ;; change-lane ;; show (word caller " ERROR corrected" ) ] ] end to check-selection [ caller ] let patch-to-test selected-patch if patch-to-test = nobody [ stop ] let side patch-set nobody let left-neighbor nobody let right-neighbor nobody ask patch-to-test [ sprout 1 [ set side neighbors with [ pcolor != 5 ] set left-neighbor patch-left-and-ahead 90 1 set right-neighbor patch-right-and-ahead 90 1 die ] ] if count side = 3 ;; between crossroads [ if lane = "left" and [ pcolor ] of left-neighbor = 5 [ if who = witness [ show ( word caller " POSSIBLE ERROR: left-driver chose wrong lane" ) ] ;; change-lane ;; if who = witness [ show ( word caller " POSSIBLE ERROR corrected, will change lane" ) ] ] if lane = "right" and [ pcolor ] of right-neighbor = 5 [ if who = witness [ show ( word caller " POSSIBLE ERROR: right-driver chose wrong lane" ) ] ;; change-lane ;; if who = witness [ show ( word caller " POSSIBLE ERROR corrected, will change lane" ) ] ] ] end to-report work-home-distance [ h ] let w h + commuting-distance if h > 48 [ set w w - 96 ] report w end to find-correct-heading-from [ resting-place ] face resting-place if lane = "left" [ right 90 ] if lane = "right" [ left 90 ] end to return-to-work let start-patch one-of neighbors with [ pcolor = 5 and not occupied? and distance myself = 1 ] if start-patch != nobody [ let resting-place patch-here move-to start-patch if who = witness [ show ( word "leaving my home " resting-place ", starting from " start-patch ) ] find-correct-heading-from resting-place set at-home? false set just-left? true set from-work? false set from-home? true set moves-after-return 0 ] check-direction "return-to-work" end to return-home let start-patch one-of neighbors with [ pcolor = 5 and not occupied? and distance myself = 1 ] if start-patch != nobody [ let resting-place patch-here move-to start-patch if who = witness [ show ( word "leaving my work " resting-place ", starting from " start-patch ) ] find-correct-heading-from resting-place set at-home? false set at-work? false set just-left? true set from-work? true set from-home? false set moves-after-return 0 ] check-direction "return-home" end to update-memory [ new-item ] ifelse length memory > 30 [ set memory lput new-item but-first memory ] [ set memory lput new-item memory ] end to go if ERROR_OCCURRED or ERROR_COUNT > 10 [ stop ] if decision-rule = "ISING" [ let left-drivers count cars with [ lane = "left" ] let right-drivers count cars with [ lane = "right" ] ask cars [ set perception ( left-drivers - right-drivers ) / ( left-drivers + right-drivers ) ] ] if decision-rule = "NORM HI" [ ask cars [ set strength abs perception ] ] ask cars with [ at-home? = 0 ] [ set at-home? false set at-work? false ] ask cars with [ not at-home? and not at-work? ] [ find-out-where-to-go ] ask cars with [ not at-home? and not at-work? ] [ select-possible-patch ] ask cars with [ not at-home? and not at-work? ] [ go-to-selected-patch ] ask cars with [ at-home? and ( ( ticks - at-home-since ) > 3 ) ] [ ;; show ( word at-home? " ticks= " ticks " at home since " at-home-since ) return-to-work ] ask cars with [ at-work? and ( ( ticks - at-work-since ) > 3 ) ] [ ;; show ( word at-work? " ticks= " ticks " at home since " at-work-since ) return-home ] tick if not any? cars with [ not at-home? or not at-work? ] [ stop ] if ticks - last-change > 20 and ticks - last-conflict > 20 [ stop ] end to find-out-where-to-go ask neighbors [ set allowable? false ] set possible-patches neighbors with [ pcolor = 5 and not occupied? ] set list-of-possible-patches [ list pxcor pycor ] of possible-patches ask possible-patches [ set allowable? true ] if who = witness [ show ( word "I am at " list xcor ycor ) show ( word "find-out-where-to-go " list-of-possible-patches ) show ( word "find-out-where-to-go " [ occupied? ] of possible-patches ) ] end to-report conflict? let result false let possible-conflicts turtle-set nobody let mylane lane let the-one-in-front-of-me one-of turtles-on patch-ahead 1 if who = witness [ show ( word the-one-in-front-of-me " is in front of me, my position is " type-of-current-position ) ] if the-one-in-front-of-me != nobody [ if [ lane ] of the-one-in-front-of-me != mylane [ set result true ] set cars-opposite turtle-set the-one-in-front-of-me if who = witness [ show ( word "in front:" list lane [ lane ] of the-one-in-front-of-me ) ] ] if not result and type-of-current-position = "i-am-at-a-crossroad" [ ifelse lane = "right" [ let car-1 one-of turtles-on patch-right-and-ahead 90 sqrt-2 let car-2 one-of turtles-on patch-ahead 3 let car-3 one-of turtles-on patch-left-and-ahead 135 ( 2 * sqrt-2 ) set possible-conflicts ( turtle-set car-1 car-2 car-3 ) ] [ let car-1 one-of turtles-on patch-left-and-ahead 90 sqrt-2 let car-2 one-of turtles-on patch-ahead 3 let car-3 one-of turtles-on patch-right-and-ahead 135 ( 2 * sqrt-2 ) set possible-conflicts ( turtle-set car-1 car-2 car-3 ) ] if who = witness [ show ( word "at crossroad: " list lane [ lane ] of possible-conflicts ) ] if count possible-conflicts with [ lane != mylane ] = 3 [ set result true ] set cars-opposite turtle-set possible-conflicts with [ lane != mylane ] ] if who = witness [ show ( word "conflict " result ) ] if result [ set conflicts conflicts + 1 set last-conflict ticks ] report result end to try-to-solve-conflict let new-lane "undecided" if decision-rule = "ISING" [ let prob-left-to-right ny * exp ( delta + kappa * perception ) let prob-right-to-left ny * exp ( -1 * ( delta + kappa * perception ) ) let comparison random-float-in-range 0 1 if lane = "left" and prob-left-to-right < comparison [ set new-lane "right" ] if lane = "right" and prob-right-to-left < comparison [ set new-lane "left" ] ] if decision-rule = "LOCAL MAJORITY" [ let local-majority "left" let left-lane-neighbors count cars in-radius locality with [ lane = "left" ] let right-lane-neighbors count cars in-radius locality with [ lane = "right" ] if right-lane-neighbors > left-lane-neighbors [ set local-majority "right" ] if right-lane-neighbors = left-lane-neighbors [ set local-majority "undecided" ] set new-lane local-majority set perception ( left-lane-neighbors - right-lane-neighbors ) / ( left-lane-neighbors + right-lane-neighbors ) ] if decision-rule = "NORM EQ" [ if any? cars-opposite [ let my-lane lane let car-opposite min-one-of cars-opposite [ distance myself ] update-memory ( list car-opposite self ticks [ lane ] of car-opposite true 1 ) update-memory ( list car-opposite self ticks lane false 1 ) let my-cars-opposite cars-opposite ask cars in-radius locality [ let new-item ( list car-opposite myself ticks [ lane ] of car-opposite true 1 ) update-memory new-item set new-item ( list car-opposite myself ticks my-lane false 1 ) update-memory new-item ] ] let right-norm length filter [ ( item 3 ? = "right" and item 4 ? ) or ( item 3 ? = "left" and not item 4 ? ) ] memory let left-norm length filter [ ( item 3 ? = "left" and item 4 ? ) or ( item 3 ? = "right" and not item 4 ? ) ] memory if who = witness [ show ( word "try-to-solve-conflict: right vs. left = " ( list right-norm ":" left-norm ) ) ] if right-norm = left-norm [ set new-lane "undecided" ] ifelse right-norm + left-norm = 0 [ set perception 0 ] [ set perception ( right-norm - left-norm ) / ( right-norm + left-norm ) ] ifelse right-norm > left-norm [ set new-lane "right" ] [ set new-lane "left" ] ] if decision-rule = "NORM HI" [ if any? cars-opposite [ let my-lane lane let car-opposite max-one-of cars-opposite [ strength ] update-memory ( list car-opposite self ticks [ lane ] of car-opposite true [ strength ] of car-opposite ) update-memory ( list car-opposite self ticks lane false [ strength ] of car-opposite ) let my-cars-opposite cars-opposite ask cars in-radius locality [ let new-item ( list car-opposite myself ticks [ lane ] of car-opposite true [ strength ] of car-opposite) update-memory new-item set new-item ( list car-opposite myself ticks my-lane false [ strength ] of car-opposite ) update-memory new-item ] ] let relevant-memory-items-right filter [ ( item 3 ? = "right" and item 4 ? ) or ( item 3 ? = "left" and not item 4 ? ) ] memory let relevant-memory-items-left filter [ ( item 3 ? = "left" and item 4 ? ) or ( item 3 ? = "right" and not item 4 ? ) ] memory let right-norm sum map [ item 5 ? ] relevant-memory-items-right let left-norm sum map [ item 5 ? ] relevant-memory-items-left if who = witness [ show ( word "try-to-solve-conflict: right vs. left = " ( list right-norm ":" left-norm ) ) show relevant-memory-items-right show relevant-memory-items-left ] if right-norm = left-norm [ set new-lane "undecided" ] ifelse right-norm + left-norm = 0 [ set perception 0 ] [ set perception ( right-norm - left-norm ) / ( right-norm + left-norm ) ] ifelse right-norm > left-norm [ set new-lane "right" ] [ set new-lane "left" ] ] ;; all decision rules if new-lane = "undecided" [ ifelse random 2 = 0 [ set new-lane "left" ] [ set new-lane "right" ] ] if lane != new-lane and who = witness [ show ( word "try-to-solve-conflict " lane " to " new-lane ) ] if who = witness [ show ( word "current lane: " lane ", trajectory was " trajectory ) ] if who = witness [ show ( word type-of-current-position ) ] if lane != new-lane [ if who = witness [ show ( word "conflict solved, I change from " lane " to " new-lane ) ] change-lane right 180 ] end to clarify-position set type-of-current-position "between-crossroads" let front-left patch-left-and-ahead 45 1.4 let front-straight patch-left-and-ahead 0 1 let front-right patch-right-and-ahead 45 1.4 let back-left patch-left-and-ahead 135 1.4 let back-straight patch-left-and-ahead 180 1 let back-right patch-right-and-ahead 135 1.4 if [ pcolor ] of front-left = 5 and [ pcolor ] of front-straight = 5 and [ pcolor ] of front-right = 5 [ set type-of-current-position "i-am-at-a-crossroad" ] if [ pcolor ] of back-left = 5 and [ pcolor ] of back-straight = 5 and [ pcolor ] of back-right = 5 [ set type-of-current-position "i-just-passed-a-crossroad" ] end to select-possible-patch set selected-patch patch-here clarify-position if conflict? [ try-to-solve-conflict clarify-position ] if who = witness [ show ( word "select-possible-patch entered " [ list pxcor pycor ] of possible-patches " " type-of-current-position " " selected-patch ) ] ifelse type-of-current-position != "i-am-at-a-crossroad" [ ifelse [ allowable? ] of patch-left-and-ahead 0 1 [ set selected-patch patch-left-and-ahead 0 1 ] [ ;; set selected-patch one-of ( patch-set patch-left-and-ahead 90 1 patch-right-and-ahead 90 1 ) with [ pcolor = 5 and not occupied? ] ;; set turn-after-go 180 ] ] [ ;; I am at a crossroads, there are now three possibilities: turn left, turn right go ahead depending where my destination is ;; if lane = "right" these are (2) forward 3 / (1) forward 1 right 90 forward 1 / (3) forward 2 left 90 forward 2 ;; if lane = "left" these are (2) forward 3 / (3) forward 1 left 90 forward 1 / (1) forward 2 right 90 forward 2 ;; the second and third choices are made when this leads faster to the destination let patch-1 patch-here let patch-2 patch-here let patch-3 patch-here ifelse lane = "right" [ set patch-1 patch-right-and-ahead 45 sqrt-2 ;; right car turns right set patch-2 patch-right-and-ahead 0 3 set patch-3 patch-right-and-ahead -45 ( 2 * sqrt-2 ) ;; right car turns left ] [ set patch-3 patch-left-and-ahead 45 sqrt-2 ;; left car turns left set patch-2 patch-left-and-ahead 0 3 set patch-1 patch-left-and-ahead -45 ( 2 * sqrt-2 ) ;; left car turns right ] let reachable-patches ( patch-set patch-1 patch-2 patch-3 ) if any? reachable-patches with [ pcolor != 5 ] [ show ( word "ERROR: I am at " list xcor ycor " and can reach " [ ( list pxcor pycor pcolor ) ] of reachable-patches ) show trajectory set ERROR_OCCURRED true ] let my-workplace mywork ask reachable-patches [ set distance-to-current-occupier's-workplace distance my-workplace ] set selected-patch min-one-of reachable-patches [ distance-to-current-occupier's-workplace ] if [ occupied? ] of selected-patch [ set selected-patch one-of reachable-patches with [ pcolor = 5 and not occupied? ] ] if selected-patch != nobody [ if selected-patch = patch-1 [ set turn-after-go 90 ] if selected-patch = patch-3 [ set turn-after-go -90 ] if selected-patch = patch-2 [ set turn-after-go 0 ] ] ] if who = witness [ show ( word "leaving select-possible-patch " selected-patch " turning " turn-after-go ) ] end to change-lane if who = witness [ show ( word "change-lane entered " lane " " color-name color " heading " heading ) ] ifelse lane = "right" [ set lane "left" set color red ] [ set lane "right" set color green ] set changes changes + 1 set last-change ticks if selected-patch = patch-right-and-ahead 180 1 or selected-patch = patch-right-and-ahead 90 1 or selected-patch = patch-left-and-ahead 90 1 [ set turn-after-go 180 ] if who = witness [ show ( word "leaving change-lane " lane " " color-name color " heading " heading ) ] ;; check-direction "change-lane" end to go-to-selected-patch let eligible selected-patch != nobody and selected-patch != patch-here ;; show ( word eligible ": " selected-patch ) if eligible [ set eligible [ not occupied? ] of selected-patch ] ;; if selected-patch != nobody [ show ( word eligible ": occupied " [ occupied? ] of selected-patch ) ] if eligible [ set eligible [ pcolor ] of selected-patch = 5 ] ;; if selected-patch != nobody [ show ( word eligible ": pcolor " [ pcolor ] of selected-patch ) ] ifelse not eligible [ if who = witness [ show ( word "go-to-selected-patch entered: no move possible" ) ] stay ifelse selected-patch = nobody [ if who = witness [ show selected-patch ] ] [ if who = witness [ show ( word selected-patch " is " color-name pcolor ", occupied? " occupied? ) ] ] ] [ ;; show ( word "patch " selected-patch " may be used ...") set at-home? false set at-work? false ask patch-here [ set occupied? false ] ;; show ( word patch-here " freed" ) if who = witness [ show ( word "go-to-selected-patch: moving from " patch-here " to " selected-patch ) ] move-to selected-patch set moves-after-return moves-after-return + 1 right turn-after-go if who = witness [ show ( word "moved to " selected-patch " and turned " turn-after-go ) ] set turn-after-go 0 if [ pcolor ] of patch-at-heading-and-distance heading 1 != 5 [ show ( word "ERROR: pcolor of " [ list pxcor pycor ] of patch-at-heading-and-distance heading 1 " is " [ pcolor ] of patch-at-heading-and-distance heading 1 " heading changed by " turn-after-go ) show trajectory set ERROR_OCCURRED true ] clarify-position set trajectory lput ( list xcor ycor lane type-of-current-position heading ) trajectory ask selected-patch [ set occupied? true ] if distance mywork < 3 and not just-left? and not from-work? and moves-after-return > 10 [ ask patch-here [ set occupied? false ] move-to mywork if who = witness [ show ( word "arrived at work " mywork ) ] let local mywork set mywork myhome set myhome local set at-work? true set arrivals-at-work arrivals-at-work + 1 set at-work-since ticks ] if distance myhome < 3 and not just-left? and not from-home? and moves-after-return > 10 [ ask patch-here [ set occupied? false ] move-to myhome if who = witness [ show ( word "arrived at home " myhome ) ] let local myhome set myhome mywork set mywork local set at-home? true set at-home-since ticks set arrivals-at-home arrivals-at-home + 1 ] if moves-after-return > 5 [ set just-left? false ] check-direction "go-to-selected-patch" ] end to stay end to-report random-float-in-range [ low high ] report low + random-float ( high - low ) end to-report color-name [ a-color ] let a-name "unknown" if a-color = 5 [ set a-name "grey" ] if a-color = 15 [ set a-name "red" ] if a-color = 55 [ set a-name "green" ] report a-name end @#$#@#$#@ GRAPHICS-WINDOW 210 10 996 817 48 48 8.0 1 8 1 1 1 0 1 1 1 -48 48 -48 48 0 0 1 ticks 30.0 BUTTON 2 11 65 44 NIL setup NIL 1 T OBSERVER NIL NIL NIL NIL 1 BUTTON 67 11 142 44 go once go NIL 1 T OBSERVER NIL NIL NIL NIL 1 PLOT 1062 176 1262 326 Direction of movement NIL NIL 0.0 10.0 0.0 10.0 true true "" "" PENS "right-hand" 1.0 0 -10899396 true "" "plot count cars with [ lane = \"right\" ]" "left-hand" 1.0 0 -2674135 true "" "plot count cars with [ lane = \"left\" ]" "undecided" 1.0 0 -13345367 true "" "plot count cars with [ color = blue ]" "arrived" 1.0 0 -16777216 true "" "plot count cars with [ color != red and color != green ]" BUTTON 144 11 207 44 NIL go T 1 T OBSERVER NIL NIL NIL NIL 1 SLIDER 21 123 193 156 initial-cars initial-cars 5 200 200 5 1 NIL HORIZONTAL SLIDER 22 164 194 197 locality locality 2 50 29 1 1 NIL HORIZONTAL MONITOR 1057 386 1179 431 right count cars with [ lane = \"right\" ] 17 1 11 MONITOR 1056 430 1179 475 left count cars with [ lane = \"left\" ] 17 1 11 MONITOR 1057 478 1179 523 arrivals-at-home arrivals-at-home 17 1 11 SLIDER 23 204 195 237 commuting-distance commuting-distance 20 50 50 1 1 NIL HORIZONTAL CHOOSER 22 69 194 114 decision-rule decision-rule "ISING" "LOCAL MAJORITY" "NORM EQ" "NORM HI" 3 SLIDER 22 243 194 276 kappa kappa 0 4 0.7 0.1 1 NIL HORIZONTAL PLOT 1024 22 1224 172 Perception distribution NIL NIL -1.0 1.0 0.0 30.0 true false "set-plot-pen-mode 1\nset-plot-x-range -1.05 1.05\nset-plot-pen-color black\nset-plot-pen-interval 0.1\nset-plot-y-range 0 30" "" PENS "default" 1.0 0 -16777216 true "" "histogram [ perception ] of cars" MONITOR 1057 568 1179 613 lane changes changes 17 1 11 MONITOR 1057 523 1179 568 arrivals-at-work arrivals-at-work 17 1 11 MONITOR 1059 615 1179 660 NIL conflicts 17 1 11 MONITOR 1059 663 1181 708 NIL last-change 17 1 11 MONITOR 1058 708 1181 753 NIL last-conflict 17 1 11 MONITOR 22 511 155 556 NIL ERROR_COUNT 17 1 11 MONITOR 22 557 155 602 NIL ERROR_PRODUCER 17 1 11 MONITOR 24 604 156 649 NIL this-seed 17 1 11 SWITCH 25 766 165 799 randomise? randomise? 0 1 -1000 @#$#@#$#@ ## WHAT IS IT? In this model a number of car drivers move around over crossing streets and find their way from their homes to their working places and back. In the beginning they use the right or left lane of the streets in an arbitrary manner. When they meet an upcoming car on the same lane they do not crash but try to find a way to avoid a crash by changing the lane. ## HOW IT WORKS At every crossroads the car drivers try to use the turn-off which brings them fastest to their destination. When they encounter an upcoming car, i.e. a conflict between right-hand drivers and left-hand drivers, they find out which lane of the street is used by the majority within their vision-range and decide to switch to driving on the other side of the street and continue their way. If this is not possible they turn on the same patch and continue their way in the opposite direction, deciding at the next crossroad which turn-off brings them fastest to their destination. ## HOW TO USE IT Currently one can only change the number of cars (traffic density) and the range of vision of the car-drivers. Moreover it is possible to switch between four decision modes: * ISING: the probability of solving a conflict by changing the preferred lane is a function of the current overall majority. * LOCAL MAJORITY: in case of a conflict both cars decide to use the lane which is used by the local majority. * NORM: the conflicting cars issue norm invocations which are stored in the memories of the conflicting parties and in the memories of car drivers in the local neighbourhood; the memories store up to 30 items, older messages are deleted; they use their memories to decide about a change of their preferred lane in two different modes * NORM EQ: they just count the norm invocations in favour or right or left or * NORM HI: they weight the norm invocations in favour of right or left with the strength of the norm invocations, the latter depending on how strong the majority perceptions of the invocators were when they were memorised. With `randomise?' switched on, each run starts with a random configuration. ## THINGS TO NOTICE In most cases all car drivers arrive at their destination and find back home, perhaps several times. After some time a majority of drivers use the same lane, either driving on the left or on the right. How big the majority is and how long it takes all cars to arrive at their destinations depends on the traffic density and the range of vision. The simulation stops 20 time steps after the last conflict. ## THINGS TO TRY In a large number of simulation runs with different combinations of traffic density and range of vision the dependence of the time until all cars arrived at their destinations and the majority on traffic density and range of vision can be determined. ## EXTENDING THE MODEL It might be interesting how much the behaviour changes when the road network becomes more complicated. ## NETLOGO FEATURES ## RELATED MODELS Model 3476 by Carl Edwards is about lane changing for overtaking, not about the emergence of left-hand traffic or right-hand traffic as a legal norm. ## CREDITS AND REFERENCES The model is mentioned in Klaus G. Troitzsch: Can lawlike rules emerge without the intervention of legislators? (submitted to Frontiers in Evolutionary Sociology and Biosociology). @#$#@#$#@ default true 0 Polygon -7500403 true true 150 5 40 250 150 205 260 250 airplane true 0 Polygon -7500403 true true 150 0 135 15 120 60 120 105 15 165 15 195 120 180 135 240 105 270 120 285 150 270 180 285 210 270 165 240 180 180 285 195 285 165 180 105 180 60 165 15 arrow true 0 Polygon -7500403 true true 150 0 0 150 105 150 105 293 195 293 195 150 300 150 box false 0 Polygon -7500403 true true 150 285 285 225 285 75 150 135 Polygon -7500403 true true 150 135 15 75 150 15 285 75 Polygon -7500403 true true 15 75 15 225 150 285 150 135 Line -16777216 false 150 285 150 135 Line -16777216 false 150 135 15 75 Line -16777216 false 150 135 285 75 bug true 0 Circle -7500403 true true 96 182 108 Circle -7500403 true true 110 127 80 Circle -7500403 true true 110 75 80 Line -7500403 true 150 100 80 30 Line -7500403 true 150 100 220 30 butterfly true 0 Polygon -7500403 true true 150 165 209 199 225 225 225 255 195 270 165 255 150 240 Polygon -7500403 true true 150 165 89 198 75 225 75 255 105 270 135 255 150 240 Polygon -7500403 true true 139 148 100 105 55 90 25 90 10 105 10 135 25 180 40 195 85 194 139 163 Polygon -7500403 true true 162 150 200 105 245 90 275 90 290 105 290 135 275 180 260 195 215 195 162 165 Polygon -16777216 true false 150 255 135 225 120 150 135 120 150 105 165 120 180 150 165 225 Circle -16777216 true false 135 90 30 Line -16777216 false 150 105 195 60 Line -16777216 false 150 105 105 60 car false 0 Polygon -7500403 true true 300 180 279 164 261 144 240 135 226 132 213 106 203 84 185 63 159 50 135 50 75 60 0 150 0 165 0 225 300 225 300 180 Circle -16777216 true false 180 180 90 Circle -16777216 true false 30 180 90 Polygon -16777216 true false 162 80 132 78 134 135 209 135 194 105 189 96 180 89 Circle -7500403 true true 47 195 58 Circle -7500403 true true 195 195 58 circle false 0 Circle -7500403 true true 0 0 300 circle 2 false 0 Circle -7500403 true true 0 0 300 Circle -16777216 true false 30 30 240 cow false 0 Polygon -7500403 true true 200 193 197 249 179 249 177 196 166 187 140 189 93 191 78 179 72 211 49 209 48 181 37 149 25 120 25 89 45 72 103 84 179 75 198 76 252 64 272 81 293 103 285 121 255 121 242 118 224 167 Polygon -7500403 true true 73 210 86 251 62 249 48 208 Polygon -7500403 true true 25 114 16 195 9 204 23 213 25 200 39 123 cylinder false 0 Circle -7500403 true true 0 0 300 dot false 0 Circle -7500403 true true 90 90 120 face happy false 0 Circle -7500403 true true 8 8 285 Circle -16777216 true false 60 75 60 Circle -16777216 true false 180 75 60 Polygon -16777216 true false 150 255 90 239 62 213 47 191 67 179 90 203 109 218 150 225 192 218 210 203 227 181 251 194 236 217 212 240 face neutral false 0 Circle -7500403 true true 8 7 285 Circle -16777216 true false 60 75 60 Circle -16777216 true false 180 75 60 Rectangle -16777216 true false 60 195 240 225 face sad false 0 Circle -7500403 true true 8 8 285 Circle -16777216 true false 60 75 60 Circle -16777216 true false 180 75 60 Polygon -16777216 true false 150 168 90 184 62 210 47 232 67 244 90 220 109 205 150 198 192 205 210 220 227 242 251 229 236 206 212 183 fish false 0 Polygon -1 true false 44 131 21 87 15 86 0 120 15 150 0 180 13 214 20 212 45 166 Polygon -1 true false 135 195 119 235 95 218 76 210 46 204 60 165 Polygon -1 true false 75 45 83 77 71 103 86 114 166 78 135 60 Polygon -7500403 true true 30 136 151 77 226 81 280 119 292 146 292 160 287 170 270 195 195 210 151 212 30 166 Circle -16777216 true false 215 106 30 flag false 0 Rectangle -7500403 true true 60 15 75 300 Polygon -7500403 true true 90 150 270 90 90 30 Line -7500403 true 75 135 90 135 Line -7500403 true 75 45 90 45 flower false 0 Polygon -10899396 true false 135 120 165 165 180 210 180 240 150 300 165 300 195 240 195 195 165 135 Circle -7500403 true true 85 132 38 Circle -7500403 true true 130 147 38 Circle -7500403 true true 192 85 38 Circle -7500403 true true 85 40 38 Circle -7500403 true true 177 40 38 Circle -7500403 true true 177 132 38 Circle -7500403 true true 70 85 38 Circle -7500403 true true 130 25 38 Circle -7500403 true true 96 51 108 Circle -16777216 true false 113 68 74 Polygon -10899396 true false 189 233 219 188 249 173 279 188 234 218 Polygon -10899396 true false 180 255 150 210 105 210 75 240 135 240 house false 0 Rectangle -7500403 true true 45 120 255 285 Rectangle -16777216 true false 120 210 180 285 Polygon -7500403 true true 15 120 150 15 285 120 Line -16777216 false 30 120 270 120 leaf false 0 Polygon -7500403 true true 150 210 135 195 120 210 60 210 30 195 60 180 60 165 15 135 30 120 15 105 40 104 45 90 60 90 90 105 105 120 120 120 105 60 120 60 135 30 150 15 165 30 180 60 195 60 180 120 195 120 210 105 240 90 255 90 263 104 285 105 270 120 285 135 240 165 240 180 270 195 240 210 180 210 165 195 Polygon -7500403 true true 135 195 135 240 120 255 105 255 105 285 135 285 165 240 165 195 line true 0 Line -7500403 true 150 0 150 300 line half true 0 Line -7500403 true 150 0 150 150 pentagon false 0 Polygon -7500403 true true 150 15 15 120 60 285 240 285 285 120 person false 0 Circle -7500403 true true 110 5 80 Polygon -7500403 true true 105 90 120 195 90 285 105 300 135 300 150 225 165 300 195 300 210 285 180 195 195 90 Rectangle -7500403 true true 127 79 172 94 Polygon -7500403 true true 195 90 240 150 225 180 165 105 Polygon -7500403 true true 105 90 60 150 75 180 135 105 plant false 0 Rectangle -7500403 true true 135 90 165 300 Polygon -7500403 true true 135 255 90 210 45 195 75 255 135 285 Polygon -7500403 true true 165 255 210 210 255 195 225 255 165 285 Polygon -7500403 true true 135 180 90 135 45 120 75 180 135 210 Polygon -7500403 true true 165 180 165 210 225 180 255 120 210 135 Polygon -7500403 true true 135 105 90 60 45 45 75 105 135 135 Polygon -7500403 true true 165 105 165 135 225 105 255 45 210 60 Polygon -7500403 true true 135 90 120 45 150 15 180 45 165 90 sheep false 15 Circle -1 true true 203 65 88 Circle -1 true true 70 65 162 Circle -1 true true 150 105 120 Polygon -7500403 true false 218 120 240 165 255 165 278 120 Circle -7500403 true false 214 72 67 Rectangle -1 true true 164 223 179 298 Polygon -1 true true 45 285 30 285 30 240 15 195 45 210 Circle -1 true true 3 83 150 Rectangle -1 true true 65 221 80 296 Polygon -1 true true 195 285 210 285 210 240 240 210 195 210 Polygon -7500403 true false 276 85 285 105 302 99 294 83 Polygon -7500403 true false 219 85 210 105 193 99 201 83 square false 0 Rectangle -7500403 true true 30 30 270 270 square 2 false 0 Rectangle -7500403 true true 30 30 270 270 Rectangle -16777216 true false 60 60 240 240 star false 0 Polygon -7500403 true true 151 1 185 108 298 108 207 175 242 282 151 216 59 282 94 175 3 108 116 108 target false 0 Circle -7500403 true true 0 0 300 Circle -16777216 true false 30 30 240 Circle -7500403 true true 60 60 180 Circle -16777216 true false 90 90 120 Circle -7500403 true true 120 120 60 tree false 0 Circle -7500403 true true 118 3 94 Rectangle -6459832 true false 120 195 180 300 Circle -7500403 true true 65 21 108 Circle -7500403 true true 116 41 127 Circle -7500403 true true 45 90 120 Circle -7500403 true true 104 74 152 triangle false 0 Polygon -7500403 true true 150 30 15 255 285 255 triangle 2 false 0 Polygon -7500403 true true 150 30 15 255 285 255 Polygon -16777216 true false 151 99 225 223 75 224 truck false 0 Rectangle -7500403 true true 4 45 195 187 Polygon -7500403 true true 296 193 296 150 259 134 244 104 208 104 207 194 Rectangle -1 true false 195 60 195 105 Polygon -16777216 true false 238 112 252 141 219 141 218 112 Circle -16777216 true false 234 174 42 Rectangle -7500403 true true 181 185 214 194 Circle -16777216 true false 144 174 42 Circle -16777216 true false 24 174 42 Circle -7500403 false true 24 174 42 Circle -7500403 false true 144 174 42 Circle -7500403 false true 234 174 42 turtle true 0 Polygon -10899396 true false 215 204 240 233 246 254 228 266 215 252 193 210 Polygon -10899396 true false 195 90 225 75 245 75 260 89 269 108 261 124 240 105 225 105 210 105 Polygon -10899396 true false 105 90 75 75 55 75 40 89 31 108 39 124 60 105 75 105 90 105 Polygon -10899396 true false 132 85 134 64 107 51 108 17 150 2 192 18 192 52 169 65 172 87 Polygon -10899396 true false 85 204 60 233 54 254 72 266 85 252 107 210 Polygon -7500403 true true 119 75 179 75 209 101 224 135 220 225 175 261 128 261 81 224 74 135 88 99 wheel false 0 Circle -7500403 true true 3 3 294 Circle -16777216 true false 30 30 240 Line -7500403 true 150 285 150 15 Line -7500403 true 15 150 285 150 Circle -7500403 true true 120 120 60 Line -7500403 true 216 40 79 269 Line -7500403 true 40 84 269 221 Line -7500403 true 40 216 269 79 Line -7500403 true 84 40 221 269 wolf false 0 Polygon -16777216 true false 253 133 245 131 245 133 Polygon -7500403 true true 2 194 13 197 30 191 38 193 38 205 20 226 20 257 27 265 38 266 40 260 31 253 31 230 60 206 68 198 75 209 66 228 65 243 82 261 84 268 100 267 103 261 77 239 79 231 100 207 98 196 119 201 143 202 160 195 166 210 172 213 173 238 167 251 160 248 154 265 169 264 178 247 186 240 198 260 200 271 217 271 219 262 207 258 195 230 192 198 210 184 227 164 242 144 259 145 284 151 277 141 293 140 299 134 297 127 273 119 270 105 Polygon -7500403 true true -1 195 14 180 36 166 40 153 53 140 82 131 134 133 159 126 188 115 227 108 236 102 238 98 268 86 269 92 281 87 269 103 269 113 x false 0 Polygon -7500403 true true 270 75 225 30 30 225 75 270 Polygon -7500403 true true 30 75 75 30 270 225 225 270 @#$#@#$#@ NetLogo 5.3.1 @#$#@#$#@ @#$#@#$#@ @#$#@#$#@ setup go this-seed decision-rule kappa locality commuting-distance ERROR_COUNT ERROR_PRODUCER last-change count cars with [ lane = "right" ] changes conflicts @#$#@#$#@ @#$#@#$#@ default 0.0 -0.2 0 0.0 1.0 0.0 1 1.0 0.0 0.2 0 0.0 1.0 link direction true 0 Line -7500403 true 150 150 90 180 Line -7500403 true 150 150 210 180 @#$#@#$#@ 0 @#$#@#$#@