breed [moth] moth-own [genes] breed [bird] globals [freqD freqL year clock clock-start Lbef Dbef caught caughtL caughtD TotTime lichen] to startup reset end to reset clear-all set-default-shape bird "nuthatch" set freqD .03 set lichen 38 setup-patches setup-moths setup-bird set year 1830 end to setup-patches if year < 1835 [import-pcolors "mothbackdrop1.jpg"] if year >= 1835 and year <= 1950 [import-pcolors "mothbackdrop2.jpg"] if year > 1950 [import-pcolors "mothbackdrop3.jpg"] if year >= 1835 and year < 1900 and lichen > 0 [set lichen lichen - 3] if year > 1954 and lichen < 38 [set lichen lichen + 3] ask patches [ if pcolor = black and random 100 < 40 [set pcolor 1.3] if pcolor <= 1.3 and random 100 < lichen [set pcolor white] ] end to setup-moths if freqD < 0.05 [set freqD .05 + (random 5 / 1000)] if freqD > .75 [set freqD .7 + (random 10 / 1000)] create-moth 20 [ if random 1000 / 1000 < freqD [set genes 1] if random 1000 / 1000 < freqD [set genes genes + 1] ifelse genes < 1 [set shape "mothL"][set shape "mothd"] set ycor 5 + random 263 let x random 3 if x = 0 [set xcor 127 + random 36] if x = 1 [set xcor 210 + random 43] if x = 2 [set xcor 285 + random 38] set size 13 ] end to setup-bird create-bird 1 [ set size 55 hide-turtle ] end to go if clock-start = 0 [ set freqD (count moth with [genes = 1] + (2 * count moth with [genes = 2]))/ (count moth * 2) ask moth [die] setup-patches setup-moths set caughtL 0 set caughtd 0 set TotTime TotTime + forage-time set Lbef count moth with [genes < 1] set Dbef count moth with [genes >= 1] set clock-start timer ] set clock timer - clock-start eat-moths if clock > forage-time [ set year year + 2 set clock-start 0 ask bird [hide-turtle] set caughtL Lbef - count moth with [genes < 1] set caughtD Dbef - count moth with [genes >= 1] do-plots set clock 0 stop ] end to eat-moths ;; show the hawk shape under the mouse-pointer ask bird [ set hidden? not mouse-inside? if mouse-down? = false [setxy mouse-xcor mouse-ycor] ] if mouse-inside? and mouse-down? [ ;; prey holds an agentset of the bugs that the mouse is close to touching. ;; "close to touching" is considered to be within a circle that is equal in size to the size ;; of the bug. The shape of the bug may not take up the whole circle, but it takes up most of it. let prey moth with [distance one-of bird < (size / 2)] if any? prey [ set caught (caught + count prey) ask prey [ die ] ] ] end to do-plots set-current-plot "Dark Allele Frequency" set-current-plot-pen "FreqD" plotxy year freqD set-current-plot "relative Survival" if lbef > 0 [ set-current-plot-pen "Light" plotxy year ((lbef - caughtl) / (Lbef)) ] if dbef > 0 [ set-current-plot-pen "Dark" plotxy year ((Dbef - caughtD) / (Dbef)) ] end to skip if year < 1950 [ set year 1950 set freqD .75 set lichen 0 ] end @#$#@#$#@ GRAPHICS-WINDOW 205 10 917 581 -1 -1 2.0 1 10 1 1 1 0 0 0 1 0 350 0 269 0 0 1 ticks BUTTON 38 10 102 43 NIL Reset NIL 1 T OBSERVER NIL NIL NIL NIL MONITOR 116 113 186 170 Light count moth with [genes < 1] / count moth 3 1 14 MONITOR 45 113 114 170 Dark count moth with [genes > 0] / count moth 3 1 14 BUTTON 319 415 393 472 NIL Go T 1 T OBSERVER NIL NIL NIL NIL MONITOR 234 415 317 472 NIL Year 17 1 14 MONITOR 319 473 393 530 Timer Forage-time - Clock 0 1 14 SLIDER 39 46 196 79 Forage-time Forage-time 1 10 5 1 1 sec HORIZONTAL PLOT 24 289 203 413 Dark Allele Frequency NIL NIL 1830.0 2010.0 0.0 1.0 true false PENS "freqd" 1.0 0 -16777216 true PLOT 24 416 203 546 Relative Survival NIL NIL 1830.0 2010.0 0.0 1.0 true true PENS "Dark" 1.0 0 -16777216 true "Light" 1.0 0 -14835848 true MONITOR 234 473 317 530 Catch Rate caught / Tottime 3 1 14 BUTTON 104 11 196 44 Skip to 1950 skip NIL 1 T OBSERVER NIL NIL NIL NIL TEXTBOX 43 92 221 114 Phenotype Frequencies 14 0.0 1 TEXTBOX 65 192 215 210 Allele Frequencies 14 0.0 1 MONITOR 46 212 115 269 Dark FreqD 2 1 14 MONITOR 117 212 186 269 Light 1 - freqD 2 1 14 @#$#@#$#@ WHAT IS IT? ----------- This section could give a general understanding of what the model is trying to show or explain. HOW IT WORKS ------------ This section could explain what rules the agents use to create the overall behavior of the model. HOW TO USE IT ------------- This section could explain how to use the model, including a description of each of the items in the interface tab. THINGS TO NOTICE ---------------- This section could give some ideas of things for the user to notice while running the model. THINGS TO TRY ------------- This section could give some ideas of things for the user to try to do (move sliders, switches, etc.) with the model. EXTENDING THE MODEL ------------------- This section could give some ideas of things to add or change in the procedures tab to make the model more complicated, detailed, accurate, etc. NETLOGO FEATURES ---------------- This section could point out any especially interesting or unusual features of NetLogo that the model makes use of, particularly in the Procedures tab. It might also point out places where workarounds were needed because of missing features. RELATED MODELS -------------- This section could give the names of models in the NetLogo Models Library or elsewhere which are of related interest. CREDITS AND REFERENCES ---------------------- This section could contain a reference to the model's URL on the web if it has one, as well as any other necessary credits or references. @#$#@#$#@ 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 bird false 0 Polygon -6459832 true false 12 223 44 196 48 188 108 149 117 132 131 132 134 135 138 143 140 157 125 173 109 205 67 216 42 211 Polygon -16777216 true false 115 156 115 180 102 200 49 203 96 198 111 178 Polygon -955883 true false 139 144 162 156 139 158 134 150 Polygon -955883 true false 84 209 90 229 109 234 90 232 80 234 88 228 79 210 Circle -16777216 true false 122 140 8 Line -16777216 false 137 151 157 154 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 hawk false 0 Polygon -7500403 true true 151 170 136 170 123 229 143 244 156 244 179 229 166 170 Polygon -16777216 true false 152 154 137 154 125 213 140 229 159 229 179 214 167 154 Polygon -7500403 true true 151 140 136 140 126 202 139 214 159 214 176 200 166 140 Polygon -16777216 true false 151 125 134 124 128 188 140 198 161 197 174 188 166 125 Polygon -7500403 true true 152 86 227 72 286 97 272 101 294 117 276 118 287 131 270 131 278 141 264 138 267 145 228 150 153 147 Polygon -7500403 true true 160 74 159 61 149 54 130 53 139 62 133 81 127 113 129 149 134 177 150 206 168 179 172 147 169 111 Circle -16777216 true false 144 55 7 Polygon -16777216 true false 129 53 135 58 139 54 Polygon -7500403 true true 148 86 73 72 14 97 28 101 6 117 24 118 13 131 30 131 22 141 36 138 33 145 72 150 147 147 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 mothd true 1 Polygon -16777216 true false 150 40 164 42 231 95 278 150 294 188 256 232 161 237 148 224 137 238 112 244 53 242 9 195 25 148 132 45 mothl true 0 Polygon -1 true false 144 40 158 42 225 95 272 150 288 188 250 232 155 237 142 224 131 238 106 244 47 242 3 195 19 148 126 45 Rectangle -16777216 true false 45 150 45 165 Rectangle -16777216 true false 56 166 73 186 Rectangle -16777216 true false 39 135 57 155 Rectangle -16777216 true false 19 195 37 214 Rectangle -16777216 true false 58 150 76 170 Rectangle -16777216 true false 18 172 35 189 Rectangle -16777216 true false 81 158 100 177 Rectangle -16777216 true false 73 125 92 147 Rectangle -16777216 true false 60 223 76 242 Rectangle -16777216 true false 41 192 58 211 Rectangle -16777216 true false 76 192 93 210 Rectangle -16777216 true false 84 210 100 227 Rectangle -16777216 true false 44 221 58 237 Rectangle -16777216 true false 114 136 129 157 Rectangle -16777216 true false 94 77 111 98 Rectangle -16777216 true false 95 148 114 166 Rectangle -16777216 true false 102 103 121 124 Rectangle -16777216 true false 74 88 89 107 Rectangle -16777216 true false 113 55 131 73 Rectangle -16777216 true false 186 73 204 94 Rectangle -16777216 true false 114 189 130 208 Rectangle -16777216 true false 144 197 160 214 Rectangle -16777216 true false 151 103 171 124 Rectangle -16777216 true false 135 72 154 92 Rectangle -16777216 true false 129 42 146 59 Rectangle -16777216 true false 165 70 176 83 Rectangle -16777216 true false 150 135 169 151 Rectangle -16777216 true false 192 93 212 115 Rectangle -16777216 true false 145 148 163 167 Rectangle -16777216 true false 124 108 144 128 Rectangle -16777216 true false 167 216 185 234 Rectangle -16777216 true false 57 103 73 120 Rectangle -16777216 true false 86 87 98 106 Rectangle -16777216 true false 50 125 70 145 Rectangle -16777216 true false 18 146 39 167 Rectangle -16777216 true false 204 185 221 203 Rectangle -16777216 true false 158 169 176 187 Rectangle -16777216 true false 237 169 248 182 Rectangle -16777216 true false 186 168 203 188 Rectangle -16777216 true false 211 216 231 234 Rectangle -16777216 true false 243 211 260 228 Rectangle -16777216 true false 271 178 289 197 Rectangle -16777216 true false 218 114 235 133 Rectangle -16777216 true false 227 160 238 173 Rectangle -16777216 true false 199 137 214 154 Rectangle -16777216 true false 247 134 263 153 Rectangle -16777216 true false 231 183 246 201 Rectangle -16777216 true false 262 196 273 209 Rectangle -16777216 true false 249 185 266 202 Rectangle -16777216 true false 225 206 241 222 Rectangle -16777216 true false 233 115 250 134 Rectangle -16777216 true false 246 157 263 178 Rectangle -16777216 true false 227 142 244 159 Rectangle -16777216 true false 263 149 279 167 Rectangle -16777216 true false 215 94 232 115 Rectangle -16777216 true false 88 230 104 246 Rectangle -16777216 true false 93 170 115 190 Rectangle -16777216 true false 118 226 129 239 Rectangle -16777216 true false 97 216 115 235 Rectangle -16777216 true false 143 212 154 225 Rectangle -16777216 true false 160 70 176 86 Rectangle -16777216 true false 183 124 202 142 Rectangle -16777216 true false 172 97 190 116 Rectangle -16777216 true false 185 63 196 76 Rectangle -16777216 true false 150 39 166 58 nuthatch false 0 Polygon -6459832 true false 158 144 177 131 187 133 204 134 234 122 261 102 267 74 256 40 267 -4 242 45 225 59 204 74 190 95 169 99 161 114 162 126 152 147 Polygon -13791810 true false 155 141 171 121 194 111 199 118 248 49 242 49 265 0 235 51 202 76 191 94 167 101 159 116 161 128 152 146 Circle -16777216 true false 168 114 6 Polygon -1 true false 155 144 173 124 196 116 195 128 186 132 176 130 Polygon -1 true false 260 19 250 49 241 56 237 62 259 52 255 38 Polygon -1 true false 199 119 217 103 208 104 Line -16777216 false 233 58 210 87 Line -16777216 false 244 53 198 117 Polygon -16777216 true false 154 144 172 119 192 114 199 103 195 117 177 122 Polygon -955883 true false 251 110 255 119 260 113 263 120 254 121 256 137 253 139 251 115 247 110 Polygon -955883 true false 262 81 266 90 271 84 274 91 265 93 267 108 264 110 262 86 258 81 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 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 4.1 @#$#@#$#@ @#$#@#$#@ @#$#@#$#@ @#$#@#$#@ @#$#@#$#@ 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 @#$#@#$#@