cakewalk
Model was written in NetLogo 6.4.0
•
Viewed 2 times
•
Downloaded 1 time
•
Run 0 times
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
globals [ dead-house-list list-of-target-lists list-of-player-names number-of-players player-lineup step-list] ;; global variable that tracks dead houses ;; all players' target lists ;; all player names corresponding to the target lists ;; number of players total ;; roster of player numbers in the current run ;; list of the current step each turtle is on breed [people person] people-own [target points target-list player-name step] breed [houses house] houses-own [value-of-house] to setup clear-all set dead-house-list [] ;; initialize the variable as an empty list set step-list (n-values number-of-people [0]) ;; initialize as a list of zeros set number-of-houses 20 ;; set the slider since this is hard-coded for 20 houses set-default-shape houses "house" ifelse game-type = "Random" [ create-houses number-of-houses ] ;; CREATE-ORDERED-distributes the houses evenly [ create-ordered-houses number-of-houses [ fd max-pxcor ] ] if game-type = "Random" [ ask houses [ setxy random-xcor random-ycor ] ] ;;this starts houses at random coordinates let sorted-turtles sort turtles ; sorted-turtles sort turtles =/ foreach sorted-turtles [ x -> ask x [ ; x is the house ID let y (who - 1) set value-of-house y ; set each house value to its ID plus once since IDs start at zero set value-of-house value-of-house + 1 ; this gives house values 0-99 if game-type = "Spiral"[ let z who facexy 0 0 ; Put the houses in a spiral configuration, with the distance from (0,0) corresponding to their relative value fd ((19 - who) * .75) ] ] ] create-people number-of-people [ ;; setxy random-xcor random-ycor ;;this would start everyone at random coordinates setxy 0 0 ;; start everyone in the center set target one-of houses set size 1.15 set points 0 ;; these are the points that we're measuring set step 0 ;; steps synchronize the evaluation of which people are on a house at a given time face target ] ;; Player names here set list-of-player-names [ "Sweepy" "Lilac" "Zinnia" "Marigold" "Daffodil" "Mac" "Timmy" "7" "8" "9" "10" "11" "12" "13" "14" ] ;; can have more players available than are active on a given run set number-of-players length list-of-player-names ;; Turtle target lists are here set list-of-target-lists [ [19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0] ; Player0 [17 15 13 11 10 9 8 7 6 5 4 19 18 3 2 1 16 14 12 0] ; Player1 [18 15 19 17 16 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0] ; Player2 [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 0] ; Player3 [19 18 15 14 13 10 9 8 7 6 5 4 3 2 1 17 16 12 11 0] ; Player4 [10 11 9 12 8 13 7 14 6 15 7 16 6 17 7 18 8 19 9 0] ; Player5 [18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 19] ; Player6 [8 7 6 5 4 3 2 1 0 19 9 10 11 12 13 14 15 16 17 18] ; Player7 [12 11 10 9 8 7 6 5 4 3 2 1 0 19 17 15 13 14 16 18] ; Player8 [19 18 10 9 8 7 6 5 4 3 2 1 0 17 16 15 14 13 12 11] ; Player9 [6 5 4 3 2 1 0 19 7 8 9 10 11 12 13 14 15 16 17 18] ; Player10 [11 1 11 11]; Player11 [12 12 12 12]; Player12 [18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 19]; Player13 [17 16 15 13 12 10 9 6 5 4 3 2 1 0 19]; Player14 ] ;; Assign target lists ask turtle 20 ;; turtle number is hard coded for # houses setup [ set target-list item Player1-Number list-of-target-lists set target house first target-list ;; Set target face target set player-name item Player1-Number list-of-player-names ] if number-of-people > 1 [ ask turtle 21 ;; turtle number is hard coded for # houses setup [ set target-list item Player2-Number list-of-target-lists set target house first target-list face target set player-name item Player2-Number list-of-player-names ] ] if number-of-people > 2 [ ask turtle 22 ;; turtle number is hard coded for # houses setup [ set target-list item Player3-Number list-of-target-lists set target house first target-list face target set player-name item Player3-Number list-of-player-names ] ] if number-of-people > 3 [ ask turtle 23 ;; turtle number is hard coded for # houses setup [ set target-list item Player4-Number list-of-target-lists set target house first target-list face target set player-name item Player4-Number list-of-player-names ] ] if number-of-people > 4 [ ask turtle 24 ;; turtle number is hard coded for # houses setup [ set target-list item Player5-Number list-of-target-lists set target house first target-list face target set player-name item Player5-Number list-of-player-names ] ] if number-of-people > 5 [ ask turtle 25 ;; turtle number is hard coded for # houses setup [ set target-list item Player6-Number list-of-target-lists set target house first target-list face target set player-name item Player6-Number list-of-player-names ] ] if number-of-people > 6 [ ask turtle 26 ;; turtle number is hard coded for # houses setup [ set target-list item Player7-Number list-of-target-lists set target house first target-list face target set player-name item Player7-Number list-of-player-names ] ] if number-of-people > 7 [ ask turtle 27 ;; turtle number is hard coded for # houses setup [ set target-list item Player8-Number list-of-target-lists set target house first target-list face target set player-name item Player8-Number list-of-player-names ] ] if number-of-people > 8 [ ask turtle 28 ;; turtle number is hard coded for # houses setup [ set target-list item Player9-Number list-of-target-lists set target house first target-list face target set player-name item Player9-Number list-of-player-names ] ] if number-of-people > 9 [ ask turtle 29 ;; turtle number is hard coded for # houses setup [ set target-list item Player10-Number list-of-target-lists set target house first target-list face target set player-name item Player10-Number list-of-player-names ] ] if number-of-people > 10 [ ask turtle 30 ;; turtle number is hard coded for # houses setup [ set target-list item Player11-Number list-of-target-lists set target house first target-list face target set player-name item Player11-Number list-of-player-names ] ] if number-of-people > 11 [ ask turtle 31 ;; turtle number is hard coded for # houses setup [ set target-list item Player12-Number list-of-target-lists set target house first target-list face target set player-name item Player12-Number list-of-player-names ] ] if number-of-people > 12 [ ask turtle 32 ;; turtle number is hard coded for # houses setup [ set target-list item Player13-Number list-of-target-lists set target house first target-list face target set player-name item Player13-Number list-of-player-names ] ] if number-of-people > 13 [ ask turtle 33 ;; turtle number is hard coded for # houses setup [ set target-list item Player14-Number list-of-target-lists set target house first target-list face target set player-name item Player14-Number list-of-player-names ] ] if number-of-people > 14 [ ask turtle 34 ;; turtle number is hard coded for # houses setup [ set target-list item Player15-Number list-of-target-lists set target house first target-list face target set player-name item Player15-Number list-of-player-names ] ] reset-ticks end to grab-cash ; people procedure ;if number-of-houses = 0 [ stop ] ; stop the run when there are no more houses let prey one-of houses-here ; grab a random house if prey != nobody ; did we get one? if so, [ let y [ value-of-house ] of prey ; value-from has been deprecated in this version of Netlogo, so use 'of' set dead-house-list lput y dead-house-list ; add the dead house value (which is also its ID) to the list ask prey [ die ] ; grab the house, and... set number-of-houses number-of-houses - 1 ; use this to set the stop condition, drives the slider down if not any? other turtles-here ; only give points if there is not a tie - nobody gets points if there's a tie [ set points points + y ] ; people get points value from grabbing the cash ] end to go if number-of-houses = 0 [ stop ] ; stop the run when there are no more houses let step-size 1 if fine-steps? [ set step-size 0.1 ] if game-type = "Moving" [ ask houses [ fd (house-speed * step-size) ] ] ;; moving the houses ;; This is to stop BehaviorSpace runs that contain multiple iterations of the same player ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; if block-dupes? [ set player-lineup (list Player1-Number Player2-Number Player3-Number Player4-Number Player5-Number Player6-Number Player7-Number Player8-Number Player9-Number Player10-Number Player11-Number Player12-Number Player13-Number Player14-Number Player15-Number) let deduped-player-lineup remove-duplicates player-lineup if length player-lineup != length deduped-player-lineup [ ask people [ set points -1 ] stop ] ] display-values ;; show the value of each house next to the house ask people [ display-labels ;; show the player names next to the arrows let cleaned-list filter [ x -> not member? x dead-house-list ] target-list ;; update the target-list to remove any values on the dead-house-list set target-list cleaned-list if target-list = [] [ stop ] ; stop the run when the target list is empty if target = nobody ;; case where target not picked off already [ set target house first target-list ;; set the target to the next one on the list ] face target set step (step + 1) let step-synch false set step-list (replace-item (who - 20) step-list step) ;;;;;!!!!! ;; move towards target. once the distance is less than 2 step-sizes, ;; use move-to to land exactly on the target. ifelse distance target < ( 2 * step-size) ;;Takes about an extra click to eat the house if this is set to 1 vs. 2 [ move-to target ] ;;because the fractional distance costs a whole click, but with fine movement increments of 0.1 this is irrelevant [ fd step-size ] ] ;; evaluate whether all turtles have moved and are now on the same step by checking if all the steps in the step-list are identical let step-synch false if (length remove-duplicates step-list) = 1 [ set step-synch true ] ;; if at target, choose a new target ask people [ let cleaned-list filter [ x -> not member? x dead-house-list ] target-list ;; update the target-list to remove any values on the dead-house-list set target-list cleaned-list if target-list = [] [ stop ] ; stop the run when the target list is empty if target = nobody ;; case where target not picked off already [ set target house first target-list ;; set the target to the next one on the list ] face target if ((distance target = 0) and (step-synch)) [ grab-cash ;; people grab the cash on their patch, based on Wolf Sheep Predation "eat-sheep" set cleaned-list filter [ x -> not member? x dead-house-list ] target-list ;; update the target-list to remove any values on the dead-house-list set target-list cleaned-list ;; if target-list = [] [ stop ] ; stop the run when the target list is empty set target house first target-list face target ] ] tick end to display-values ask houses [ set label " " ] if show-values? [ ask houses [ set label value-of-house ] ] end to display-labels ask people [ set label " " ] if show-names? [ ask people [ set label player-name ] ] end
There is only one version of this model, created about 10 hours ago by Ian Chapman.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
cakewalk.png | preview | Preview for 'cakewalk' | about 10 hours ago, by Ian Chapman | Download |
This model does not have any ancestors.
This model does not have any descendants.