Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- globals [name]
- to go
- ;; user-input lets the user type in a string
- if name = 0.0 ;; has name been set yet?
- [ set name user-input "What is your name?" ]
- ;; read-from-string will convert a string into a number
- let num read-from-string
- user-input "How many turtles would you like?"
- ;; user-choice gives the user a set of choices
- ;; runresult runs a NetLogo reporter held in a string
- let col runresult
- user-one-of "What color should the turtles be?"
- ["red + 1" "blue - 2" "green + 3"]
- ;; make the turtles
- create-turtles num
- [ set color col
- fd random-float max-pxcor ]
- display
- ;; user-message tells the user something
- user-message (word "OK, " name ", there are "
- count turtles " turtles now.")
- ;; user-yes-or-no? asks the user a yes-or-no question
- if not user-yes-or-no? "Would you like more turtles?"
- [ stop ]
- end
- ; Public Domain:
- ; To the extent possible under law, Uri Wilensky has waived all
- ; copyright and related or neighboring rights to this model.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement