Line of Sight Example
Model was written in NetLogo 5.0.4
•
Viewed 578 times
•
Downloaded 95 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 [walkers walker] breed [markers marker] patches-own [elevation] to setup clear-all set-default-shape markers "dot" ;; setup the terrain ask patches [ set elevation random 10000 ] repeat 2 [ diffuse elevation 1 ] ask patches [ set pcolor scale-color green elevation 1000 9000 ] create-walkers 6 [ set size 1.5 setxy random-xcor random-ycor set color item who [orange blue magenta violet brown yellow] mark-line-of-sight ] reset-ticks end to go ;; get rid of all the old markers ask markers [ die ] ;; move the walkers ask walkers [ rt random 10 lt random 10 fd 1 mark-line-of-sight ] tick end to mark-line-of-sight ;; walker procedure let dist 1 let a1 0 let c color let last-patch patch-here ;; iterate through all the patches ;; starting at the patch directly ahead ;; going through MAXIMUM-VISIBILITY while [dist <= maximum-visibility] [ let p patch-ahead dist ;; if we are looking diagonally across ;; a patch it is possible we'll get the ;; same patch for distance x and x + 1 ;; but we don't need to check again. if p != last-patch [ ;; find the angle between the turtle's position ;; and the top of the patch. let a2 atan dist (elevation - [elevation] of p) ;; if that angle is less than the angle toward the ;; last visible patch there is no direct line from the turtle ;; to the patch in question that is not obstructed by another ;; patch. if a1 < a2 [ ask p [ sprout-markers 1 [ set color c ] ] set a1 a2 ] set last-patch p ] set dist dist + 1 ] 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 | |
---|---|---|---|---|
Line of Sight Example.png | preview | Preview for 'Line of Sight Example' | over 11 years ago, by Uri Wilensky | Download |
This model does not have any ancestors.
This model does not have any descendants.