MIHS Challenge 2 - solution

MIHS Challenge 2 - solution preview image

1 collaborator

Larry_bencivengo Larry Bencivengo (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by the author
Model was written in NetLogo 5.2.0 • Viewed 121 times • Downloaded 15 times • Run 0 times
Download the 'MIHS Challenge 2 - solution' modelDownload this modelEmbed this model

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 [predators predator]      ;; this statement declares a new breed of turtles called "predators"
breed [bugs bug]                ;; the first name refers to ALL bugs; the second name can refer to
                                ;; one specific bug (for example bug 7)

to setup
  clear-all
  set-default-shape bugs "bug"  ;; sets the default shape for ALL bugs
  set-default-shape predators "circle"
  create-bugs 10
  ask bugs 
  [
    setxy random-xcor random-ycor
  ]
  ask bug 7                     ;; asks one specific bug to make itself bigger
  [
    set size 2
  ]    
  ;; the predator breed contains one turtle that is used to represent
  ;; a predator of the bugs (a menacing circle)
  create-predators 1 
  [
    set shape "circle"
    set color white
    set size 1.5
    set heading 315
    setxy 0 0
  ]
  reset-ticks
end 

to go               ;; when the "go" button is clicked, this loop repeats until the button is clicked again
  move-bugs         ;; this calls the procedure named "move-bugs" defined below
  move-predator     ;; this calls the procedure named "move-predator"
  tick
end 

to move-bugs        ;; this makes the bugs move when it is "called" from the "to go" loop above
  ask bugs          ;; asks ALL bugs to move
  [
    fd .5           ;; forward 1 step
    rt random 10    ;; turn right
    lt random 10    ;; turn left
  ]
    ask bug 7 [fd 1]     ;; asks one specific bug to make an extra move
end  

to move-predator    ;; this makes the predators move
  ask predators
  [
    fd 1            ;; forward 1 step
    rt random 10    ;; turn right
    lt random 10    ;; turn left
  ]
end 

There is only one version of this model, created about 8 years ago by Larry Bencivengo.

Attached files

File Type Description Last updated
MIHS Challenge 2 - solution.png preview Preview for 'MIHS Challenge 2 - solution' about 8 years ago, by Larry Bencivengo Download

This model does not have any ancestors.

This model does not have any descendants.