File Output Example
Model was written in NetLogo 5.0.4
•
Viewed 2178 times
•
Downloaded 164 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
Click to Run Model
turtles-own [ value ] ;; This is some phony turtle variable ;; This procedure creates 15 random turtles and opens a file dictated ;; by the user. It will erase any pre-existing file. to setup clear-all crt 15 [ setxy random-xcor random-ycor set value 5 ] let file user-new-file ;; We check to make sure we actually got a string just in case ;; the user hits the cancel button. if is-string? file [ ;; If the file already exists, we begin by deleting it, otherwise ;; new data would be appended to the old contents. if file-exists? file [ file-delete file ] file-open file ;; record the initial turtle data write-to-file ] end ;; This procedure makes the turtles move randomly. It also changes their internal ;; variable by random +/- 1. We report the patch coordinates and their internal variable ;; to the file. To view the file, hit the file-close button and open it with a text ;; editor. to go ask turtles [ lt random 360 fd 1 + random 4 set value value + random 3 ] tick write-to-file end to write-to-file file-print (word "---------- Tick Number: " ticks "-----------") ;; use SORT so the turtles print their data in order by who number, ;; rather than in random order foreach sort turtles [ ask ? [ file-print (word self ": pxcor: " pxcor " pycor: " pycor " value: " value) ] ] file-print "" ;; blank line 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 | |
---|---|---|---|---|
File Output Example.png | preview | Preview for 'File Output Example' | over 11 years ago, by Uri Wilensky | Download |
This model does not have any ancestors.
This model does not have any descendants.