Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- to setup
- clear-all
- set-default-shape turtles "square"
- ;; make green atoms on left
- ask patches with [pxcor < 0]
- [ sprout 1 [ set color green ] ]
- ;; make blue atoms on right
- ask patches with [pxcor > 0]
- [ sprout 1 [ set color blue ] ]
- ;; plot the initial state of the system
- reset-ticks
- end
- to go
- ;; asks vacancies to ask a neighboring atom to
- ;; move into the vacancy
- ask patches with [not any? turtles-here]
- [ move-atom-to-here ]
- tick
- end
- ;; chooses a neighboring atom to move onto a empty patch (vacancy)
- to move-atom-to-here ;; patch procedure
- let atom one-of turtles-on neighbors4
- if atom != nobody [
- ask atom [ move-to myself ] ;; myself is the calling patch
- ]
- end
- ;;; plotting procedures
- to-report greens
- report turtles with [color = green]
- end
- to-report blues
- report turtles with [color = blue]
- end
- to plot-atoms [atoms]
- plot-pen-reset
- plot-pen-up
- let column min-pxcor
- repeat world-width [
- let y count atoms with [pxcor = column]
- plotxy column y
- plot-pen-down
- set column column + 1
- plotxy column y
- ]
- end
- ; Copyright 2007 Uri Wilensky.
- ; See Info tab for full copyright and license.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement