Gatherer Model v2
No preview image
Model was written in NetLogo 5.0.4
•
Viewed 402 times
•
Downloaded 33 times
•
Run 0 times
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
Info tab cannot be displayed because of an encoding error
Comments and Questions
Please start the discussion about this model!
(You'll first need to log in.)
Click to Run Model
breed [hunters hunter] breed [gatherers gatherer] breed [rabbits rabbit] hunters-own [ energy patience has-rabbit? ] gatherers-own [has-food? energy ] rabbits-own [ energy ] to setup clear-all set-default-shape hunters "person" ;; create hunters set-default-shape gatherers "person" ;; create hunters set-default-shape rabbits "rabbit" ask patches [ ifelse random-float 100 < density [set pcolor yellow] ;; scatter food [set pcolor green] ] create-hunters number [ set color red set size 5 set energy 100 setxy random-xcor random-ycor set patience 100 set has-rabbit? false ] create-gatherers number2 [ set color white set size 5 set energy 100 setxy random-xcor random-ycor set has-food? false ] create-rabbits number3 [ set color brown set size 3 set energy 50 setxy random-xcor random-ycor ] reset-ticks end to go ;; AH: Adding correct indentation here makes it a lot easier to read and code. Just highlight and press tab. :) ask turtles [ move ask gatherers with [not has-food?] [find-food] ask gatherers with [has-food?] [find-pile] ask gatherers with [not has-food?] [ if energy < 70 [eat-food]] ask hunters with [not has-rabbit?] [hunt-rabbits] ask hunters with [has-rabbit? and energy < 70] [eat-rabbit] if ticks mod 500 = 0 [set energy (energy - 5)] ask rabbits [reproduce-rabbits] ask rabbits with [energy < 40] [rabbit-eat] harvest-time ask turtles with [energy <= 0] [die] ] tick end ;; We move in a separate procedure to move fd 1 rt 20 - random 40 end ;; You call this procedure recursively and move around, instead of moving around for each tick, and then calling this ;; procedure. to find-food ;; we pick up food only if there is not already a lot of food around it ;; (i.e. on at least three patches) if pcolor = yellow and count neighbors with [pcolor = yellow] < 3 [ ;; pick up food set has-food? true ;; remove food from patch set pcolor green ] end to eat-food if pcolor = yellow and count neighbors with [pcolor = yellow] > 2 [ set pcolor green set energy (energy + 5)] end to find-pile if pcolor = yellow and [pcolor] of patch-ahead 1 != yellow [ ask patch-ahead 1 [set pcolor yellow] set has-food? false ] end to harvest-time if ticks mod 1500 = 0 [ ask one-of patches with [pcolor != yellow and count neighbors with [pcolor = yellow] < 3] [set pcolor yellow] ] end to hunt-rabbits let prey one-of rabbits-here ;; grab a random sheepi if prey != nobody ;; did we get one? if so, [ ask prey [ die ] set has-rabbit? true] ;; get energy from eating end to eat-rabbit set has-rabbit? false set energy energy + 10 end to reproduce-rabbits ;; sheep procedure if random-float 100000 < rabbit-reproduce [ ;; throw "dice" to see if you will reproduce ;; divide energy between parent and offspring hatch 1 [ rt random 360 fd 1 ] ;; hatch an offspring and move it forward 1 step ] end to rabbit-eat if pcolor = yellow [set pcolor green] set energy energy + 7 end
There are 2 versions of this model.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
AudreyHosford_May20.docx | word | Progress Report 5/20 | over 11 years ago, by Audrey Hosford | Download |
AudreyHosford_May27.docx | word | Progress Report 5/27 | over 11 years ago, by Audrey Hosford | Download |