Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. globals [name]
  2.  
  3. to go
  4. ;; user-input lets the user type in a string
  5. if name = 0.0 ;; has name been set yet?
  6. [ set name user-input "What is your name?" ]
  7.  
  8. ;; read-from-string will convert a string into a number
  9. let num read-from-string
  10. user-input "How many turtles would you like?"
  11.  
  12. ;; user-choice gives the user a set of choices
  13. ;; runresult runs a NetLogo reporter held in a string
  14. let col runresult
  15. user-one-of "What color should the turtles be?"
  16. ["red + 1" "blue - 2" "green + 3"]
  17.  
  18. ;; make the turtles
  19. create-turtles num
  20. [ set color col
  21. fd random-float max-pxcor ]
  22.  
  23. display
  24.  
  25. ;; user-message tells the user something
  26. user-message (word "OK, " name ", there are "
  27. count turtles " turtles now.")
  28.  
  29. ;; user-yes-or-no? asks the user a yes-or-no question
  30. if not user-yes-or-no? "Would you like more turtles?"
  31. [ stop ]
  32. end
  33.  
  34.  
  35. ; Public Domain:
  36. ; To the extent possible under law, Uri Wilensky has waived all
  37. ; copyright and related or neighboring rights to this model.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement