Gatherer Model v1

No preview image

1 collaborator

Default-person Audrey Hosford (Author)

Tags

(This model has yet to be categorized with any tags)
Part of project 'Hunter-Gatherer Final Project'
Model group MAM-2013 | Visible to everyone | Changeable by everyone
Model was written in NetLogo 5.0.4 • Viewed 419 times • Downloaded 26 times • Run 0 times
Download the 'Gatherer Model v1' modelDownload this modelEmbed this model

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

turtles-own [has-food?]

to setup
  clear-all
  set-default-shape turtles "person" ;; create hunters
  ask patches
  [ ifelse random-float 100 < density 
    [set pcolor yellow] ;; scatter food
    [set pcolor green] ]
  create-turtles number [
    set color white
    set size 5
    setxy random-xcor random-ycor
    set has-food? false
  ]
  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 turtles with [not has-food?] [find-food]
    ask turtles with [has-food?] [find-pile]
;    place-food
;    eat-food
;    check-dead 
    ]
  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
  ;; AH: If you use ifelse, you should use equals, and not 'not equals', if just for readability. The else-bracket here
  ;; is executed when the pcolor is not not yellow, which just doesn't read very well.

  ;; AH: If the pcolor is yellow you move forward until the pcolor is not yellow.
  ;; If the pcolor is not yellow, then you set the pcolor to green, set the color of the gatherer to red
  ;; and move forward 10 in some random direction. I am not sure what you are trying to do here.

;; old code
;    ifelse pcolor != yellow
;    [ set pcolor green
;      set color red
;      rt random 360
;      fd 10 ]
;    [fd 1
;      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 find-pile
  ;; old code
;  ;; AH: You call this procedure recursively too.
;  if pcolor != yellow
;  [rt random 360
;    fd 1
;    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 place-food
;  ;; AH: You call this procedure recursively too.
;  ifelse pcolor = yellow
;  [ ask patch-ahead 1 [ set pcolor yellow ] 
;    set color white
;    rt random 360
;    fd 5
;  ]
;  [ rt random 360
;    fd 10
;    place-food
;  ]
;end

;to eat-food
;  ;; This procedure runs the find-pile procedure which you have already run, and then sets
;  ;; the color of the patch that the turtle ends up on to green. I get that 
;  find-pile
;  set pcolor green
;end

;to check-dead
;  ;; You ask all turtles to check if all patches are not yellow, and only then do you check 
;  ;; the color of the turtle to see if it should die. I am really not sure what you are trying to do here.
;  if not any? patches with [pcolor = yellow]
;   [ if color = white [ die ] ]
;end

There is only one version of this model, created over 11 years ago by Audrey Hosford.

Attached files

File Type Description Last updated
AudreyHosford_May13.docx word Progress Report 5/13 over 11 years ago, by Audrey Hosford Download

This model does not have any ancestors.

This model does not have any descendants.