camofl
No preview image
Model was written in NetLogo 5.0beta4
•
Viewed 222 times
•
Downloaded 24 times
•
Run 3 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
breed [bugs bug] bugs-own [ birthday hue ] globals [adult-age total-caught] breed [predators predator] to setup clear-all set adult-age 2 ;; take 2 seconds to grow to full size set-default-shape bugs "moth" set-default-shape predators "bird" change-environment make-initial-bugs make-predator reset-ticks end to go reset-timer grow-bugs eat-bugs reproduce-bugs ;; update the view 20 times a second every 0.05 [ display ] ;; keep the tick counter in sync with how many seconds have passed. ;; we don't only want to count the time that passes while the GO ;; button is actually down, so that's why we do RESET-TIMER above, ;; so we can measure how time has actually been spent in GO. tick-advance timer ;; plotting takes time, so only plot 10 times a second every 0.1 [ update-plots ] end ;;;;;;;;;;;;;;;;;;; ;; Setup Procedures ;;;;;;;;;;;;;;;;;;; to make-initial-bugs create-bugs carrying-capacity [ set size bug-size set birthday (- adult-age) ;; start at full size set hue random 130 ask n-of 1 bugs [set hue 16] set color hue setxy random-xcor random-ycor ] end ;; creates the turtle that will follow the mouse pointer around and ;; represent the predator that the user is controlling to make-predator create-predators 1 [ set color yellow set size 2 hide-turtle set heading 310 ] end ;;;;;;;;;;;;;;;;;;;;; ;; Runtime Procedures ;;;;;;;;;;;;;;;;;;;;; to grow-bugs ask bugs [ ;; show genotypes ;; grow the newly hatched offspring until they reach their ADULT-AGE, ;; at which point they should be the full BUG-SIZE let age ticks - birthday ifelse age < adult-age [ set size bug-size * age / adult-age ] [ set size bug-size ] ] end to eat-bugs ;; show the hawk shape under the mouse-pointer ask predators [ set hidden? not mouse-inside? 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 bugs with [distance one-of predators < (size / 2)] if any? prey [ set total-caught (total-caught + count prey) ;; increment the number of bugs caught in this interval ask prey [ die ] ] ] end to reproduce-bugs ;; if the number of bugs in under the carrying capacity, bugs can generate offspring ;; otherwise no new bugs are to replace ones that are eaten if not any? bugs [ make-initial-bugs ] if count bugs < carrying-capacity - 5 [ ask one-of bugs [ make-one-offspring ] ] end ;; ask every bug to make one offspring (no carrying-capacity limitations are placed on this) to make-generation ask bugs [ make-one-offspring ] end to make-one-offspring ;; turtle procedure ;; three possible random mutations can occur, one in each frequency of gene expression ;; the max-mutation-step determines the maximum amount the gene frequency can drift up ;; or down in this offspring hatch 1 [ set size 0 if mutations = 0 [ set hue hue] if mutations = 1 [set hue hue + 1] if mutations = 2 [set hue hue + 2] if mutations = 3 [ set hue hue + 3 ] if mutations = 4 [ set hue hue + 4] if mutations = 5 [set hue hue + 5] set color hue set birthday ticks wander ] end to wander ;; turtle procedure, makes bugs wander around randomly rt random 360 fd random-float (9) end ;; imposes a threshold limit on gene-frequency. ;; without this genes could drift into negative values or very large values ;; (any value above 100%) to change-environment if environment = "poppyfield" [ import-drawing "poppyfield.jpg"] if environment = "sea" [ import-drawing "corals.jpg"] if environment = "jungle" [import-drawing "jungle.jpg"] end ;; a visualization technique to find bugs if you are convinced they are not there anymore ;; it allows flashing without actually changing and recalculating the color attribute of the bugs to flash-bugs ;; we use ASK-CONCURRENT here instead of ASK because when ;; the bugs WAIT, we want them all to wait together, not each ;; wait one at a time. ask-concurrent bugs [ let old-color color repeat 3 [ set color black display wait 0.1 set color white display wait 0.1 ] set color old-color ] display end
There is only one version of this model, created about 13 years ago by Pratim Sengupta.
Attached files
No files
This model does not have any ancestors.
This model does not have any descendants.