globals [boom-shot level ;; your current level number-of-collisions goal ;; the goal number of booms in the current level score ;; your current score new-score number-of-balls ] breed [boom-spots boom-spot] breed [balls ball] breed [players player] ;; sets up the AI player. turtles-own [turtle-size is-collided boom-count radius radiusboom] patches-own [] to setup-repeat clear-turtles clear-patches reset-ticks ;; the ticks have to reset, or the AI will only work the first time. ;; make colorful balls set-goal set-default-shape balls "circle" set-default-shape boom-spots "circle" set-default-shape players "triangle" if ai = true ;; If ai is turned on, then draw the Player turtle. [ create-players 1 [setxy random-xcor random-ycor set color white set size 20] ] create-balls number-of-balls [ set color one-of remove black base-colors setxy random-xcor random-ycor if abs pxcor = max-pxcor [ set xcor ( abs xcor - 1 ) ] if abs pycor = max-pycor [ set ycor ( abs ycor - 1) ] set size 15 set radius size / 2 set boom-count 0 set is-collided 1] set boom-shot 0 end to setup ;; turtles ;; (for this model to work with NetLogo's new plotting features, ;; __clear-all-and-reset-ticks should be replaced with clear-all at ;; the beginning of your setup procedure and reset-ticks at the end ;; of the procedure.) clear-all set level 1 set score 0 setup-repeat reset-ticks end to set-goal ifelse game = true [ if level = 1 [ set goal 1 set number-of-balls 5 ] if level = 2 [ set goal 2 set number-of-balls 10 ] if level = 3 [ set goal 3 set number-of-balls 15 ] if level = 4 [set goal 5 set number-of-balls 20] if level = 5 [set goal 7 set number-of-balls 25] if level = 6 [set goal 10 set number-of-balls 30] if level = 7 [set goal 15 set number-of-balls 35] if level = 8 [set goal 21 set number-of-balls 40] if level = 9 [set goal 27 set number-of-balls 45] if level = 10 [set goal 33 set number-of-balls 50] if level = 11 [set goal 44 set number-of-balls 55] if level = 12 [set goal 55 set number-of-balls 60] if level = 13 [ user-message "OMG YOU WON. YOU ARE THE WINNER!!!. \nTreat yourself to a taco or something." set level 1 set-goal] ][set goal 0 set number-of-balls number-of-balls-manual] end to end-level if number-of-collisions >= goal [ user-message word "Good job! \nYou got " number-of-collisions set level (level + 1) set new-score (new-score + number-of-collisions) ] if number-of-collisions < goal [ifelse number-of-collisions != goal - 1 [ user-message word "You failed to achieve your goal. \nYou only got " number-of-collisions ;;and then play again at given level set new-score (new-score) ] [ user-message word "So close! Just one away! \nYou only got " number-of-collisions ;;and then play again at given level set new-score (new-score) ]] end to go boom every .02 [ask turtles [ if is-collided = 2 [set size size + 1 if size >= 100 [set is-collided 3]] if is-collided = 3 [ set boom-count ticks set is-collided 4] ;; get round number if is-collided = 4 [if ticks >= boom-count + 200 [set is-collided 5]] ;; if it has been 10 rounds then move to 4 if is-collided = 5[ ;; when set collided is equal to 3 the circle is full size ;;set boom-count boom-count + 1 ;;if boom-count > 50 set size size - .5 if size < .5[die] ] if breed != boom-spots [ bounce fd 1 ] if breed = players [ai-move] ]] collision-detect calc-score-level if not any? boom-spots and boom-shot = -666 [end-level setup-repeat] tick end to boom if mouse-down? and boom-shot != -666 [crt 1 [set breed boom-spots setxy mouse-xcor mouse-ycor set is-collided 2 set color lput 125 extract-rgb color] set boom-shot -666] end to ai-move ;; AI feature for the turtle to randomly move around the space and place a boom if ai = true ;; if ai is on, then allow the player to move around randomly [ rt random 15 lt random 15 if not can-move? 1 [ rt 180 ] fd player-speed if ticks >= time-to-boom ;; if the number of ticks gone by is less than the slider, then do the following. [set breed boom-spots set is-collided 2 set boom-shot -666 set color lput 125 extract-rgb color] ;; is similar to the mouse function ] end to bounce ;; balls procedure ;; bounce off left and right walls if abs pxcor = max-pxcor [ set heading (- heading) ] ;; bounce off top and bottom walls if abs pycor = max-pycor [ set heading (180 - heading) ] end to collision-detect ;; balls procedure ask boom-spots [ set radiusboom size / 2 ask turtles in-radius (radiusboom + 1) with [is-collided = 1] [set is-collided 2 set breed boom-spots set color lput 125 extract-rgb color] ] end to calc-score-level set number-of-collisions (number-of-balls - (count balls)) set score (number-of-collisions) end to calc-overall-score set number-of-collisions (number-of-balls -(count balls)) set new-score (number-of-collisions) end @#$#@#$#@ GRAPHICS-WINDOW 199 10 802 472 296 215 1.0 1 10 1 1 1 0 0 0 1 -296 296 -215 215 0 0 1 ticks 30.0 BUTTON 115 22 178 55 Play! go T 1 T OBSERVER NIL NIL NIL NIL 1 BUTTON 17 22 112 55 New Game setup NIL 1 T OBSERVER NIL NIL NIL NIL 1 MONITOR 134 57 191 102 Score score 0 1 11 MONITOR 18 57 75 102 Level Level 0 1 11 MONITOR 76 57 133 102 Goal Goal 0 1 11 MONITOR 18 103 192 148 Number of balls in play number-of-balls 0 1 11 SLIDER 18 150 198 183 number-of-balls-manual number-of-balls-manual 0 100 53 1 1 NIL HORIZONTAL SWITCH 18 187 108 220 game game 0 1 -1000 SLIDER 18 223 198 256 time-to-boom time-to-boom 0 5000 1879 1 1 NIL HORIZONTAL SWITCH 108 187 198 220 ai ai 0 1 -1000 SLIDER 18 259 198 292 player-speed player-speed 0 5 2 .5 1 NIL HORIZONTAL MONITOR 78 294 135 339 ticks ticks 17 1 11 MONITOR 76 367 158 412 Total Score new-score 17 1 11 @#$#@#$#@ ## WHAT IS IT? This is a model of the internet game Boomshine created by Danny Miller. You, the player, have one opportunity, a boomshot, to click and create the longest chain reaction possible or a set number of explosions to achieve an estabilished goal. This requires the player to monitor the behavior of the circular turtles and choose an optimal boomshot location. ## HOW IT WORKS When a boomshot is clicked, a turtle is created that expands to a set radius around the center of clicked point, shrinks to a radius of zero and dies. Once this boomshot happens, the turtle is said to have boomed. If a turtle contacts the boomshot during any of its time-elasped life period, the turtles stop moving at point of contact and similarly expand, contract, then die. If new turtles continue to contact boomed turtles, a chain reaction continues until no new contacts are made with a boomed turtle during its life span. Players who are better at choosing the location of the boomshot in relation to other turtles to achieve the longest chain reaction will receive higher scores. ## HOW TO USE IT Buttons: -New Game: resets the game. Game starts at level one. -Play: starts the game from level one or at the level at which the game was halted. Monitors: -Level: there are 12 levels with 1) a set number of balls in play, and 2) the goal needed to be achieved for completion. -Goal: the number of collisions needed to complete the level. -Total Score: the total score across levels, which is equal to the sum of the score at the beginning of a level and the number of collisions made when the goal of the given level is met. -Score: automatically updated within levels to show how many turtles have been boomed as a result of your boomshot. -Number of balls in play: the number of balls on the screen. -Ticks: shows number of ticks from the time play button was clicked until last turtle has boomed and died. Switch: -AI: a computer based agent that moves at a set speed and booms after a set number of ticks have elasped. -Game: when game is 'On,' levels are preset; when game is 'Off,' the player can manually adjust the number of balls in play. Slider: -number-of-balls-manual: a manually adjusted number of balls on the patch. (n.b. This parameter is adjusted by the observer and is only available when the game is 'Off.') -time-to-boom: sets how many ticks it takes before the AI turtle booms. -player-speed: sets how fast the AI turtle moves. ## THINGS TO NOTICE How is the score affected if both the AI and you take a boomshot in the same Play? That is, take your boomshot before the AI booms. Does the score improve with two boomshots--yours and the AI's random boomshot? Are there levels that the AI can complete faster compared to other levels? How does adjusting both the time-to-boom and player-speed affect the number of ticks it takes for the AI complete the level? How does adjusting both the time-to-boom and player-speed affect the score of the AI with a different 'Number of balls in play'? ## THINGS TO TRY Game "On" and AI "Off": See if you can get through all levels. Try to beat your previous score. Game "Off" and AI "Off": See if you can get all the balls to boom while varying the intial number of balls. See if it is easier to boom more balls with a greater number of balls in play Game "On" and AI "On": Compare your score with that of the AI at the different levels. See if the AI can get through all the levels. Game "Off" and AI "On": See what is the highest score that can be achieved by adjusting both time-to-boom and player-speed. ## EXTENDING THE MODEL Adjust the AI based player so that it becomes smart. That is, it moves around and expolodes in an optimal manner to create the longest chain reaction (time) or with the most number of turtles. Gather performance data from players--what determines where they click? Add bonuses or penalities for exceeding or not reaching the goal, respectively. Restrict the number of times one could fail to achieve the goals (e.g., number of lives available to the player) in order to complete all 12 levels. ## NETLOGO FEATURES This model uses breeds to implement the different moving game pieces. MOUSE-DOWN?, MOUSE-XCOR, and MOUSE-YCOR are used to detect and handle mouse clicks. USER-MESSAGE WORD are used to relay information to the user about their performance in the game. COLOR LPUT, and EXTRACT-RGB COLOR are used to allow the turtles to become transparent when they overlap. ## CREDITS AND REFERENCES The present model was created by Delia Shelton, Eriko Atagi, Justin Keene, and Travis Ross, under the guidance of Tom Busey, in fulfillment of the NetLogo capstone requirement for COGS Q530 at Indiana University. ## HOW TO CITE If you mention this model in a publication, we ask that you include these citations for the model itself and for the NetLogo software: - Shelton, D.S., Atagi, E., Keene, J.R., and Ross, T. (2015). NetLogo Boomshakalaka Model. Indiana University, Bloomington, IN. - Wilensky, U. (1999). NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL. @#$#@#$#@ 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 0 Rectangle -7500403 true true 151 225 180 285 Rectangle -7500403 true true 47 225 75 285 Rectangle -7500403 true true 15 75 210 225 Circle -7500403 true true 135 75 150 Circle -16777216 true false 165 76 116 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 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.0 @#$#@#$#@ @#$#@#$#@ @#$#@#$#@ @#$#@#$#@ @#$#@#$#@ default 0.0 -0.2 0 1.0 0.0 0.0 1 1.0 0.0 0.2 0 1.0 0.0 link direction true 0 Line -7500403 true 150 150 90 180 Line -7500403 true 150 150 210 180 @#$#@#$#@ 0 @#$#@#$#@