Hill Climbing Example
Model was written in NetLogo 5.0.4
•
Viewed 1330 times
•
Downloaded 111 times
•
Run 2 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
turtles-own [ peak? ;; indicates whether a turtle has reached a "peak", ;; that is, it can no longer go "uphill" from where it stands ] to setup clear-all ;; make a landscape with hills and valleys ask n-of 100 patches [ set pcolor 120 ] ;; slightly smooth out the landscape repeat 20 [ diffuse pcolor 1 ] ;; put some turtles on patch centers in the landscape ask n-of 800 patches [ sprout 1 [ set peak? false set color red pen-down ] ] reset-ticks end to go ;; stop when all turtles are on peak if all? turtles [peak?] [ stop ] ask turtles [ ;; remember where we started let old-patch patch-here ;; to use UPHILL, the turtles specify a patch variable uphill pcolor ;; are we still where we started? if so, we didn't ;; move, so we must be on a peak if old-patch = patch-here [ set peak? true ] ] tick end ; Public Domain: ; To the extent possible under law, Uri Wilensky has waived all ; copyright and related or neighboring rights to this model.
There are 10 versions of this model.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Hill Climbing Example.png | preview | Preview for 'Hill Climbing Example' | over 11 years ago, by Uri Wilensky | Download |
This model does not have any ancestors.
This model does not have any descendants.