Guest User

CW2

a guest
Jan 6th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. links-own [counter]
  2.  
  3. to setup
  4. clear-all
  5. create-turtles NumberOfTurtles
  6. ;make-circle
  7.  
  8. ;ask turtles [ create-links-with other turtles ]
  9. ask turtles [ setxy random-xcor random-ycor
  10. set label 0
  11. set label-color red]
  12. ask links [ set thickness 0 set label 0]
  13. reset-ticks
  14. end
  15.  
  16.  
  17. to go
  18. if ticks > 4998 [stop]
  19. ask turtles [set heading random 360 fd 1
  20. create-links-with other turtles-here
  21. [
  22. set counter 0
  23. set color green
  24.  
  25. ]
  26.  
  27. ]
  28.  
  29.  
  30. ; ask links-to other turtles-here set label (label + 1)
  31. ask links [
  32. if [patch-here] of end1 = [patch-here] of end2
  33. [
  34. set counter counter + 1
  35. show counter
  36. set label ""
  37. ]
  38. ]
  39.  
  40. tick
  41.  
  42. end
  43.  
  44. to go-once
  45.  
  46. if ticks > 4999 [stop]
  47. ask turtles [set heading random 360 fd 1 ]
  48.  
  49. ; ask links-to other turtles-here set label (label + 1)
  50. ;create-network
  51.  
  52. tick
  53. make-circle
  54.  
  55. end
  56.  
  57.  
  58. to create-network
  59. ask links [
  60. if [patch-here] of end1 = [patch-here] of end2
  61. [
  62. set label counter + 1
  63. show label
  64. ]
  65. ]
  66.  
  67. end
  68.  
  69. to make-circle
  70. if show-circle? [layout-circle sort turtles (world-width / 2 - 2)]
  71. ask links[show counter]
  72.  
  73. end
Advertisement
Add Comment
Please, Sign In to add comment