Ask-Concurrent Example
Model was written in NetLogo 5.0.4
•
Viewed 686 times
•
Downloaded 73 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 [done?] ;; this is used only by GO-TURTLES-ALTERNATE to setup clear-all ask patches with [pycor = 0] [ sprout 1 [ set heading 0 ] ] reset-ticks end to go ;; make a red patch in each column ask patches with [pycor = 0] [ ask patch-at 0 (random world-height) [ set pcolor red ] ] ;; have every turtle move forward until it ;; finds the red patch in its column go-turtles tick end to go-turtles ask-concurrent turtles [ while [pcolor != red] [ fd 1 ] set pcolor black ] end ;; Here's one way to do the same thing as GO-TURTLES but using ;; ASK instead of ASK-CONCURRENT. The behavior of the turtles ;; is the same and the visual result (turtles working on their ;; task concurrently, rather than each completing its task ;; serially) is the same. Note the use of a turtles-own variable. to go-turtles-alternate ask turtles [ set done? false ] loop [ let still-moving turtles with [not done?] if not any? still-moving [ stop ] ask still-moving [ ifelse pcolor = red [ set pcolor black set done? true ] [ fd 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 | |
---|---|---|---|---|
Ask-Concurrent Example.png | preview | Preview for 'Ask-Concurrent Example' | over 11 years ago, by Uri Wilensky | Download |
This model does not have any ancestors.
This model does not have any descendants.