MIHS Challenge 3 - solution
Model was written in NetLogo 5.2.0
•
Viewed 128 times
•
Downloaded 17 times
•
Run 0 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 [leaders leader] breed [followers follower] to setup clear-all set-default-shape followers "bug" set-default-shape leaders "circle" create-followers 10 ask followers [ setxy random-xcor random-ycor ] ;; the leader breed contains one turtle that is used to represent ;; a leader of the bugs (a circle) create-leaders 1 [ set shape "circle" set color white set size 1.5 hide-turtle ] reset-ticks end to go move-followers move-leader tick end to move-followers ;; followers will face toward the leader, then move forward ask followers ;; with a slight random wiggle [ if not [hidden?] of leader 10 ;; checks to make sure the leader is visible [face leader 10] ;; the leader is the 11th turtle created, so it has "who" # 10 ;; (the followers have "who" #'s 0-9). This checks to see if the leader ;; is present in the view fd .5 ;; forward 1 step rt random 10 ;; turn right lt random 10 ;; turn left ] end to move-leader ;; this code makes the leader appear at the same position as the cursor ask leaders ;; when the cursor is not inside the world, the leader is hidden [ setxy mouse-xcor mouse-ycor ;; only show the leader if the mouse pointer is ;; actually inside the view set hidden? not mouse-inside? ;; "mouse-inside?" checks to see if the mouse is inside the world view ;; when the mouse is outside the world view window, ;; the leader is toggled to hidden ] 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 3 - solution.png | preview | Preview for 'MIHS Challenge 3 - solution' | about 8 years ago, by Larry Bencivengo | Download |
This model does not have any ancestors.
This model does not have any descendants.