Advertisement
Guest User

lu.nlogo

a guest
Aug 2nd, 2014
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 1.95 KB | None | 0 0
  1. breed [ passengers pax ] ;pax = passenger
  2. breed [ drivers driver ]
  3.  
  4. drivers-own [ aggressiveness ]
  5.  
  6. to init-model
  7.   clear-all
  8.   random-seed new-seed
  9.   init-globals
  10.   create-drivers init-drivers
  11.   create-passengers init-passengers
  12.   ask patches [init-patch]
  13.   ask turtles [init-turtle]
  14.   reset-ticks
  15. end
  16.  
  17. to update-model
  18.   update-globals
  19.   ask patches [update-patch]
  20.   ask turtles [update-turtle]
  21.   tick
  22. end
  23.  
  24. to init-globals
  25.   ; initialize globals here
  26. end
  27.  
  28. to init-patch
  29.   ; initialize patches here
  30. end
  31.  
  32. to init-turtle
  33.   ifelse is-driver? self [ init-driver ] [ init-pax ]
  34. end
  35.  
  36. to init-driver
  37.   set shape "car"
  38.   setxy random-xcor random-ycor
  39. end
  40.  
  41. to init-pax
  42.   set shape "person"
  43.   setxy random-xcor random-ycor
  44. end
  45.  
  46. to update-globals
  47.   ; update global variables here
  48. end
  49.  
  50. to update-patch
  51.   ; update patches here
  52. end
  53.  
  54. ;this conditional just checks whether its a driver or pax
  55. to update-turtle
  56.   ifelse is-driver? self [ update-driver ] [ update-pax ]
  57. end
  58.  
  59. to update-pax
  60.    ; add commands
  61. end
  62.  
  63. to update-driver
  64.   ask patches in-cone driver-radius 360 [ set pcolor black ] ;tell all nearby patches near a car to set its self to black in a radius of 360
  65.   driver-move ;calls the move function below
  66.   ask patches in-cone driver-radius 360
  67.       [ set pcolor scale-color [color] of myself driver-radius 0 15 ] ;tell all nearby patches near a car to set its self to a shade of the car's own color in a radius of 360
  68.       ;increase the fade depending on the radius lookout of the car,
  69.       ;currently being manually set my global slider
  70. end
  71.  
  72. to driver-move
  73.   rt random 360
  74.   fd 1
  75. end
  76.  
  77. ;here we are creating different behaviors
  78.  
  79.   ;drivers that go towards crowds
  80.  
  81.   ;drivers that stay away from crowds
  82.  
  83.   ;color patches based on near-by driver count
  84.  
  85.   ;hatch-pax on world click
  86.  
  87.   ;create links when nearest driver is found
  88.  
  89.   ;increase looking radius of a car after x amount of ticks, or a modulus of ticks
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement