Logo Bolo: a re-envisioning of the classic tank game by Stuart Cheshire in NetLogo
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

534 рядки
12 KiB

  1. ;; lobo: Logo Bolo
  2. ;; (c) Ben Kurtovic, 2011
  3. ;;
  4. ;; Logo Bolo is a re-envisioning of the classic tank game by Stuart Cheshire in NetLogo.
  5. ;;
  6. ;; ============
  7. ;; Declarations
  8. ;; ============
  9. __includes [
  10. "bullet.nls"
  11. "player.nls"
  12. "tank.nls"
  13. ]
  14. globals [
  15. last-tick-time
  16. max-fps
  17. mouse-was-down?
  18. player
  19. player-accelerate-for
  20. ]
  21. ;; ===========================
  22. ;; Button-initiated procedures
  23. ;; ===========================
  24. to setup
  25. clear-all
  26. no-display
  27. setup-defaults
  28. ask patches [
  29. set pcolor random 3
  30. ]
  31. spawn-player
  32. display
  33. no-display
  34. set last-tick-time timer
  35. end
  36. to go
  37. ask player [
  38. do-player-logic
  39. ]
  40. ask tanks [
  41. do-tank-logic
  42. ]
  43. ask bullets [
  44. do-bullet-logic
  45. ]
  46. render
  47. keep-time
  48. end
  49. ;; ================
  50. ;; Other procedures
  51. ;; ================
  52. to setup-defaults
  53. set-patch-size 30
  54. resize-world -8 8 -8 8
  55. set max-fps 30
  56. set mouse-was-down? false
  57. set player-accelerate-for 0
  58. end
  59. to render
  60. display
  61. no-display
  62. end
  63. to keep-time
  64. let time-since-last-tick timer - last-tick-time
  65. let wait-time (1 / max-fps) - time-since-last-tick
  66. wait wait-time
  67. tick
  68. set last-tick-time timer
  69. end
  70. @#$#@#$#@
  71. GRAPHICS-WINDOW
  72. 475
  73. 10
  74. 995
  75. 551
  76. 8
  77. 8
  78. 30.0
  79. 1
  80. 10
  81. 1
  82. 1
  83. 1
  84. 0
  85. 1
  86. 1
  87. 1
  88. -8
  89. 8
  90. -8
  91. 8
  92. 0
  93. 0
  94. 1
  95. ticks
  96. BUTTON
  97. 66
  98. 100
  99. 161
  100. 133
  101. New Game
  102. setup
  103. NIL
  104. 1
  105. T
  106. OBSERVER
  107. NIL
  108. R
  109. NIL
  110. NIL
  111. BUTTON
  112. 313
  113. 99
  114. 407
  115. 132
  116. Play Game
  117. go
  118. T
  119. 1
  120. T
  121. OBSERVER
  122. NIL
  123. G
  124. NIL
  125. NIL
  126. MONITOR
  127. 297
  128. 382
  129. 410
  130. 427
  131. Player Speed
  132. [speed] of player
  133. 8
  134. 1
  135. 11
  136. BUTTON
  137. 108
  138. 176
  139. 285
  140. 252
  141. FIRE!
  142. player-fire
  143. NIL
  144. 1
  145. T
  146. OBSERVER
  147. NIL
  148. F
  149. NIL
  150. NIL
  151. MONITOR
  152. 296
  153. 433
  154. 410
  155. 478
  156. Player Accel Time
  157. player-accelerate-for
  158. 5
  159. 1
  160. 11
  161. @#$#@#$#@
  162. WHAT IS IT?
  163. -----------
  164. This section could give a general understanding of what the model is trying to show or explain.
  165. HOW IT WORKS
  166. ------------
  167. This section could explain what rules the agents use to create the overall behavior of the model.
  168. HOW TO USE IT
  169. -------------
  170. This section could explain how to use the model, including a description of each of the items in the interface tab.
  171. THINGS TO NOTICE
  172. ----------------
  173. This section could give some ideas of things for the user to notice while running the model.
  174. THINGS TO TRY
  175. -------------
  176. This section could give some ideas of things for the user to try to do (move sliders, switches, etc.) with the model.
  177. EXTENDING THE MODEL
  178. -------------------
  179. This section could give some ideas of things to add or change in the procedures tab to make the model more complicated, detailed, accurate, etc.
  180. NETLOGO FEATURES
  181. ----------------
  182. This section could point out any especially interesting or unusual features of NetLogo that the model makes use of, particularly in the Procedures tab. It might also point out places where workarounds were needed because of missing features.
  183. RELATED MODELS
  184. --------------
  185. This section could give the names of models in the NetLogo Models Library or elsewhere which are of related interest.
  186. CREDITS AND REFERENCES
  187. ----------------------
  188. This section could contain a reference to the model's URL on the web if it has one, as well as any other necessary credits or references.
  189. @#$#@#$#@
  190. default
  191. true
  192. 0
  193. Polygon -7500403 true true 150 5 40 250 150 205 260 250
  194. airplane
  195. true
  196. 0
  197. Polygon -7500403 true true 150 0 135 15 120 60 120 105 15 165 15 195 120 180 135 240 105 270 120 285 150 270 180 285 210 270 165 240 180 180 285 195 285 165 180 105 180 60 165 15
  198. arrow
  199. true
  200. 0
  201. Polygon -7500403 true true 150 0 0 150 105 150 105 293 195 293 195 150 300 150
  202. box
  203. false
  204. 0
  205. Polygon -7500403 true true 150 285 285 225 285 75 150 135
  206. Polygon -7500403 true true 150 135 15 75 150 15 285 75
  207. Polygon -7500403 true true 15 75 15 225 150 285 150 135
  208. Line -16777216 false 150 285 150 135
  209. Line -16777216 false 150 135 15 75
  210. Line -16777216 false 150 135 285 75
  211. bug
  212. true
  213. 0
  214. Circle -7500403 true true 96 182 108
  215. Circle -7500403 true true 110 127 80
  216. Circle -7500403 true true 110 75 80
  217. Line -7500403 true 150 100 80 30
  218. Line -7500403 true 150 100 220 30
  219. butterfly
  220. true
  221. 0
  222. Polygon -7500403 true true 150 165 209 199 225 225 225 255 195 270 165 255 150 240
  223. Polygon -7500403 true true 150 165 89 198 75 225 75 255 105 270 135 255 150 240
  224. Polygon -7500403 true true 139 148 100 105 55 90 25 90 10 105 10 135 25 180 40 195 85 194 139 163
  225. Polygon -7500403 true true 162 150 200 105 245 90 275 90 290 105 290 135 275 180 260 195 215 195 162 165
  226. Polygon -16777216 true false 150 255 135 225 120 150 135 120 150 105 165 120 180 150 165 225
  227. Circle -16777216 true false 135 90 30
  228. Line -16777216 false 150 105 195 60
  229. Line -16777216 false 150 105 105 60
  230. car
  231. false
  232. 0
  233. Polygon -7500403 true true 300 180 279 164 261 144 240 135 226 132 213 106 203 84 185 63 159 50 135 50 75 60 0 150 0 165 0 225 300 225 300 180
  234. Circle -16777216 true false 180 180 90
  235. Circle -16777216 true false 30 180 90
  236. Polygon -16777216 true false 162 80 132 78 134 135 209 135 194 105 189 96 180 89
  237. Circle -7500403 true true 47 195 58
  238. Circle -7500403 true true 195 195 58
  239. circle
  240. false
  241. 0
  242. Circle -7500403 true true 0 0 300
  243. circle 2
  244. false
  245. 0
  246. Circle -7500403 true true 0 0 300
  247. Circle -16777216 true false 30 30 240
  248. cow
  249. false
  250. 0
  251. Polygon -7500403 true true 200 193 197 249 179 249 177 196 166 187 140 189 93 191 78 179 72 211 49 209 48 181 37 149 25 120 25 89 45 72 103 84 179 75 198 76 252 64 272 81 293 103 285 121 255 121 242 118 224 167
  252. Polygon -7500403 true true 73 210 86 251 62 249 48 208
  253. Polygon -7500403 true true 25 114 16 195 9 204 23 213 25 200 39 123
  254. cylinder
  255. false
  256. 0
  257. Circle -7500403 true true 0 0 300
  258. dot
  259. false
  260. 0
  261. Circle -7500403 true true 90 90 120
  262. face happy
  263. false
  264. 0
  265. Circle -7500403 true true 8 8 285
  266. Circle -16777216 true false 60 75 60
  267. Circle -16777216 true false 180 75 60
  268. Polygon -16777216 true false 150 255 90 239 62 213 47 191 67 179 90 203 109 218 150 225 192 218 210 203 227 181 251 194 236 217 212 240
  269. face neutral
  270. false
  271. 0
  272. Circle -7500403 true true 8 7 285
  273. Circle -16777216 true false 60 75 60
  274. Circle -16777216 true false 180 75 60
  275. Rectangle -16777216 true false 60 195 240 225
  276. face sad
  277. false
  278. 0
  279. Circle -7500403 true true 8 8 285
  280. Circle -16777216 true false 60 75 60
  281. Circle -16777216 true false 180 75 60
  282. Polygon -16777216 true false 150 168 90 184 62 210 47 232 67 244 90 220 109 205 150 198 192 205 210 220 227 242 251 229 236 206 212 183
  283. fish
  284. false
  285. 0
  286. Polygon -1 true false 44 131 21 87 15 86 0 120 15 150 0 180 13 214 20 212 45 166
  287. Polygon -1 true false 135 195 119 235 95 218 76 210 46 204 60 165
  288. Polygon -1 true false 75 45 83 77 71 103 86 114 166 78 135 60
  289. Polygon -7500403 true true 30 136 151 77 226 81 280 119 292 146 292 160 287 170 270 195 195 210 151 212 30 166
  290. Circle -16777216 true false 215 106 30
  291. flag
  292. false
  293. 0
  294. Rectangle -7500403 true true 60 15 75 300
  295. Polygon -7500403 true true 90 150 270 90 90 30
  296. Line -7500403 true 75 135 90 135
  297. Line -7500403 true 75 45 90 45
  298. flower
  299. false
  300. 0
  301. Polygon -10899396 true false 135 120 165 165 180 210 180 240 150 300 165 300 195 240 195 195 165 135
  302. Circle -7500403 true true 85 132 38
  303. Circle -7500403 true true 130 147 38
  304. Circle -7500403 true true 192 85 38
  305. Circle -7500403 true true 85 40 38
  306. Circle -7500403 true true 177 40 38
  307. Circle -7500403 true true 177 132 38
  308. Circle -7500403 true true 70 85 38
  309. Circle -7500403 true true 130 25 38
  310. Circle -7500403 true true 96 51 108
  311. Circle -16777216 true false 113 68 74
  312. Polygon -10899396 true false 189 233 219 188 249 173 279 188 234 218
  313. Polygon -10899396 true false 180 255 150 210 105 210 75 240 135 240
  314. house
  315. false
  316. 0
  317. Rectangle -7500403 true true 45 120 255 285
  318. Rectangle -16777216 true false 120 210 180 285
  319. Polygon -7500403 true true 15 120 150 15 285 120
  320. Line -16777216 false 30 120 270 120
  321. leaf
  322. false
  323. 0
  324. Polygon -7500403 true true 150 210 135 195 120 210 60 210 30 195 60 180 60 165 15 135 30 120 15 105 40 104 45 90 60 90 90 105 105 120 120 120 105 60 120 60 135 30 150 15 165 30 180 60 195 60 180 120 195 120 210 105 240 90 255 90 263 104 285 105 270 120 285 135 240 165 240 180 270 195 240 210 180 210 165 195
  325. Polygon -7500403 true true 135 195 135 240 120 255 105 255 105 285 135 285 165 240 165 195
  326. line
  327. true
  328. 0
  329. Line -7500403 true 150 0 150 300
  330. line half
  331. true
  332. 0
  333. Line -7500403 true 150 0 150 150
  334. pentagon
  335. false
  336. 0
  337. Polygon -7500403 true true 150 15 15 120 60 285 240 285 285 120
  338. person
  339. false
  340. 0
  341. Circle -7500403 true true 110 5 80
  342. Polygon -7500403 true true 105 90 120 195 90 285 105 300 135 300 150 225 165 300 195 300 210 285 180 195 195 90
  343. Rectangle -7500403 true true 127 79 172 94
  344. Polygon -7500403 true true 195 90 240 150 225 180 165 105
  345. Polygon -7500403 true true 105 90 60 150 75 180 135 105
  346. plant
  347. false
  348. 0
  349. Rectangle -7500403 true true 135 90 165 300
  350. Polygon -7500403 true true 135 255 90 210 45 195 75 255 135 285
  351. Polygon -7500403 true true 165 255 210 210 255 195 225 255 165 285
  352. Polygon -7500403 true true 135 180 90 135 45 120 75 180 135 210
  353. Polygon -7500403 true true 165 180 165 210 225 180 255 120 210 135
  354. Polygon -7500403 true true 135 105 90 60 45 45 75 105 135 135
  355. Polygon -7500403 true true 165 105 165 135 225 105 255 45 210 60
  356. Polygon -7500403 true true 135 90 120 45 150 15 180 45 165 90
  357. sheep
  358. false
  359. 0
  360. Rectangle -7500403 true true 151 225 180 285
  361. Rectangle -7500403 true true 47 225 75 285
  362. Rectangle -7500403 true true 15 75 210 225
  363. Circle -7500403 true true 135 75 150
  364. Circle -16777216 true false 165 76 116
  365. square
  366. false
  367. 0
  368. Rectangle -7500403 true true 30 30 270 270
  369. square 2
  370. false
  371. 0
  372. Rectangle -7500403 true true 30 30 270 270
  373. Rectangle -16777216 true false 60 60 240 240
  374. star
  375. false
  376. 0
  377. Polygon -7500403 true true 151 1 185 108 298 108 207 175 242 282 151 216 59 282 94 175 3 108 116 108
  378. target
  379. false
  380. 0
  381. Circle -7500403 true true 0 0 300
  382. Circle -16777216 true false 30 30 240
  383. Circle -7500403 true true 60 60 180
  384. Circle -16777216 true false 90 90 120
  385. Circle -7500403 true true 120 120 60
  386. tree
  387. false
  388. 0
  389. Circle -7500403 true true 118 3 94
  390. Rectangle -6459832 true false 120 195 180 300
  391. Circle -7500403 true true 65 21 108
  392. Circle -7500403 true true 116 41 127
  393. Circle -7500403 true true 45 90 120
  394. Circle -7500403 true true 104 74 152
  395. triangle
  396. false
  397. 0
  398. Polygon -7500403 true true 150 30 15 255 285 255
  399. triangle 2
  400. false
  401. 0
  402. Polygon -7500403 true true 150 30 15 255 285 255
  403. Polygon -16777216 true false 151 99 225 223 75 224
  404. truck
  405. false
  406. 0
  407. Rectangle -7500403 true true 4 45 195 187
  408. Polygon -7500403 true true 296 193 296 150 259 134 244 104 208 104 207 194
  409. Rectangle -1 true false 195 60 195 105
  410. Polygon -16777216 true false 238 112 252 141 219 141 218 112
  411. Circle -16777216 true false 234 174 42
  412. Rectangle -7500403 true true 181 185 214 194
  413. Circle -16777216 true false 144 174 42
  414. Circle -16777216 true false 24 174 42
  415. Circle -7500403 false true 24 174 42
  416. Circle -7500403 false true 144 174 42
  417. Circle -7500403 false true 234 174 42
  418. turtle
  419. true
  420. 0
  421. Polygon -10899396 true false 215 204 240 233 246 254 228 266 215 252 193 210
  422. Polygon -10899396 true false 195 90 225 75 245 75 260 89 269 108 261 124 240 105 225 105 210 105
  423. Polygon -10899396 true false 105 90 75 75 55 75 40 89 31 108 39 124 60 105 75 105 90 105
  424. Polygon -10899396 true false 132 85 134 64 107 51 108 17 150 2 192 18 192 52 169 65 172 87
  425. Polygon -10899396 true false 85 204 60 233 54 254 72 266 85 252 107 210
  426. Polygon -7500403 true true 119 75 179 75 209 101 224 135 220 225 175 261 128 261 81 224 74 135 88 99
  427. wheel
  428. false
  429. 0
  430. Circle -7500403 true true 3 3 294
  431. Circle -16777216 true false 30 30 240
  432. Line -7500403 true 150 285 150 15
  433. Line -7500403 true 15 150 285 150
  434. Circle -7500403 true true 120 120 60
  435. Line -7500403 true 216 40 79 269
  436. Line -7500403 true 40 84 269 221
  437. Line -7500403 true 40 216 269 79
  438. Line -7500403 true 84 40 221 269
  439. x
  440. false
  441. 0
  442. Polygon -7500403 true true 270 75 225 30 30 225 75 270
  443. Polygon -7500403 true true 30 75 75 30 270 225 225 270
  444. @#$#@#$#@
  445. NetLogo 4.1.3
  446. @#$#@#$#@
  447. @#$#@#$#@
  448. @#$#@#$#@
  449. @#$#@#$#@
  450. @#$#@#$#@
  451. default
  452. 0.0
  453. -0.2 0 1.0 0.0
  454. 0.0 1 1.0 0.0
  455. 0.2 0 1.0 0.0
  456. link direction
  457. true
  458. 0
  459. Line -7500403 true 150 150 90 180
  460. Line -7500403 true 150 150 210 180
  461. @#$#@#$#@
  462. 0
  463. @#$#@#$#@