Logo Bolo: a re-envisioning of the classic tank game by Stuart Cheshire in NetLogo
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

619 行
12 KiB

  1. ;; lobo: Logo Bolo
  2. ;; (c) Ben Kurtovic, 2011
  3. ;;
  4. ;; Logo Bolo is a rewrite of the classic tank game by Stuart Cheshire in NetLogo.
  5. ;;
  6. ;; ============
  7. ;; Declarations
  8. ;; ============
  9. globals [
  10. last-tick-time
  11. max-fps
  12. max-tank-speed
  13. player
  14. player-turn-speed
  15. ]
  16. breed [bullets bullet]
  17. breed [tanks tank]
  18. tanks-own [
  19. speed
  20. ]
  21. ;; ===========================
  22. ;; Button-initiated procedures
  23. ;; ===========================
  24. to setup
  25. ca
  26. set max-fps 30
  27. set max-tank-speed 20
  28. set player-turn-speed 10
  29. ask patches [
  30. set pcolor random 3
  31. ]
  32. create-ordered-tanks 1 [
  33. set player (tank who)
  34. set color gray
  35. set size 2
  36. set speed 0
  37. ]
  38. set last-tick-time timer
  39. end
  40. to go
  41. do-physics
  42. keep-time
  43. end
  44. to player-go-forward
  45. ask player [
  46. if speed < max-tank-speed [
  47. set speed speed + 1
  48. ]
  49. ]
  50. end
  51. to player-slow-down
  52. ask player [
  53. if speed > 0 [
  54. set speed speed - 1
  55. ]
  56. ]
  57. end
  58. to player-turn-left
  59. ask player [
  60. lt player-turn-speed
  61. ]
  62. end
  63. to player-turn-right
  64. ask player [
  65. rt player-turn-speed
  66. ]
  67. end
  68. to player-fire
  69. ask player [
  70. fire
  71. ]
  72. end
  73. ;; ================
  74. ;; Other procedures
  75. ;; ================
  76. to fire
  77. hatch-bullets 1 [
  78. set color white
  79. ]
  80. end
  81. to do-physics
  82. ask tanks [
  83. fd speed / 40
  84. ]
  85. ask bullets [
  86. fd 1
  87. ]
  88. end
  89. to keep-time
  90. let time-since-last-tick timer - last-tick-time
  91. let wait-time (1 / max-fps) - time-since-last-tick
  92. wait wait-time
  93. tick
  94. set last-tick-time timer
  95. end
  96. @#$#@#$#@
  97. GRAPHICS-WINDOW
  98. 475
  99. 10
  100. 980
  101. 536
  102. 16
  103. 16
  104. 15.0
  105. 1
  106. 10
  107. 1
  108. 1
  109. 1
  110. 0
  111. 1
  112. 1
  113. 1
  114. -16
  115. 16
  116. -16
  117. 16
  118. 0
  119. 0
  120. 1
  121. ticks
  122. BUTTON
  123. 66
  124. 100
  125. 140
  126. 133
  127. Setup
  128. setup
  129. NIL
  130. 1
  131. T
  132. OBSERVER
  133. NIL
  134. R
  135. NIL
  136. NIL
  137. BUTTON
  138. 331
  139. 99
  140. 394
  141. 132
  142. Go
  143. go
  144. T
  145. 1
  146. T
  147. OBSERVER
  148. NIL
  149. G
  150. NIL
  151. NIL
  152. BUTTON
  153. 193
  154. 174
  155. 282
  156. 207
  157. Forward
  158. player-go-forward
  159. NIL
  160. 1
  161. T
  162. OBSERVER
  163. NIL
  164. W
  165. NIL
  166. NIL
  167. BUTTON
  168. 143
  169. 236
  170. 206
  171. 269
  172. Left
  173. player-turn-left
  174. NIL
  175. 1
  176. T
  177. OBSERVER
  178. NIL
  179. A
  180. NIL
  181. NIL
  182. BUTTON
  183. 250
  184. 235
  185. 319
  186. 268
  187. Right
  188. player-turn-right
  189. NIL
  190. 1
  191. T
  192. OBSERVER
  193. NIL
  194. D
  195. NIL
  196. NIL
  197. BUTTON
  198. 179
  199. 295
  200. 287
  201. 328
  202. Slow Down
  203. player-slow-down
  204. NIL
  205. 1
  206. T
  207. OBSERVER
  208. NIL
  209. S
  210. NIL
  211. NIL
  212. MONITOR
  213. 314
  214. 441
  215. 414
  216. 486
  217. Player Speed
  218. [speed] of player
  219. 17
  220. 1
  221. 11
  222. BUTTON
  223. 199
  224. 361
  225. 262
  226. 394
  227. FIRE!
  228. player-fire
  229. NIL
  230. 1
  231. T
  232. OBSERVER
  233. NIL
  234. NIL
  235. NIL
  236. NIL
  237. @#$#@#$#@
  238. WHAT IS IT?
  239. -----------
  240. This section could give a general understanding of what the model is trying to show or explain.
  241. HOW IT WORKS
  242. ------------
  243. This section could explain what rules the agents use to create the overall behavior of the model.
  244. HOW TO USE IT
  245. -------------
  246. This section could explain how to use the model, including a description of each of the items in the interface tab.
  247. THINGS TO NOTICE
  248. ----------------
  249. This section could give some ideas of things for the user to notice while running the model.
  250. THINGS TO TRY
  251. -------------
  252. This section could give some ideas of things for the user to try to do (move sliders, switches, etc.) with the model.
  253. EXTENDING THE MODEL
  254. -------------------
  255. 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.
  256. NETLOGO FEATURES
  257. ----------------
  258. 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.
  259. RELATED MODELS
  260. --------------
  261. This section could give the names of models in the NetLogo Models Library or elsewhere which are of related interest.
  262. CREDITS AND REFERENCES
  263. ----------------------
  264. 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.
  265. @#$#@#$#@
  266. default
  267. true
  268. 0
  269. Polygon -7500403 true true 150 5 40 250 150 205 260 250
  270. airplane
  271. true
  272. 0
  273. 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
  274. arrow
  275. true
  276. 0
  277. Polygon -7500403 true true 150 0 0 150 105 150 105 293 195 293 195 150 300 150
  278. box
  279. false
  280. 0
  281. Polygon -7500403 true true 150 285 285 225 285 75 150 135
  282. Polygon -7500403 true true 150 135 15 75 150 15 285 75
  283. Polygon -7500403 true true 15 75 15 225 150 285 150 135
  284. Line -16777216 false 150 285 150 135
  285. Line -16777216 false 150 135 15 75
  286. Line -16777216 false 150 135 285 75
  287. bug
  288. true
  289. 0
  290. Circle -7500403 true true 96 182 108
  291. Circle -7500403 true true 110 127 80
  292. Circle -7500403 true true 110 75 80
  293. Line -7500403 true 150 100 80 30
  294. Line -7500403 true 150 100 220 30
  295. butterfly
  296. true
  297. 0
  298. Polygon -7500403 true true 150 165 209 199 225 225 225 255 195 270 165 255 150 240
  299. Polygon -7500403 true true 150 165 89 198 75 225 75 255 105 270 135 255 150 240
  300. Polygon -7500403 true true 139 148 100 105 55 90 25 90 10 105 10 135 25 180 40 195 85 194 139 163
  301. Polygon -7500403 true true 162 150 200 105 245 90 275 90 290 105 290 135 275 180 260 195 215 195 162 165
  302. Polygon -16777216 true false 150 255 135 225 120 150 135 120 150 105 165 120 180 150 165 225
  303. Circle -16777216 true false 135 90 30
  304. Line -16777216 false 150 105 195 60
  305. Line -16777216 false 150 105 105 60
  306. car
  307. false
  308. 0
  309. 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
  310. Circle -16777216 true false 180 180 90
  311. Circle -16777216 true false 30 180 90
  312. Polygon -16777216 true false 162 80 132 78 134 135 209 135 194 105 189 96 180 89
  313. Circle -7500403 true true 47 195 58
  314. Circle -7500403 true true 195 195 58
  315. circle
  316. false
  317. 0
  318. Circle -7500403 true true 0 0 300
  319. circle 2
  320. false
  321. 0
  322. Circle -7500403 true true 0 0 300
  323. Circle -16777216 true false 30 30 240
  324. cow
  325. false
  326. 0
  327. 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
  328. Polygon -7500403 true true 73 210 86 251 62 249 48 208
  329. Polygon -7500403 true true 25 114 16 195 9 204 23 213 25 200 39 123
  330. cylinder
  331. false
  332. 0
  333. Circle -7500403 true true 0 0 300
  334. dot
  335. false
  336. 0
  337. Circle -7500403 true true 90 90 120
  338. face happy
  339. false
  340. 0
  341. Circle -7500403 true true 8 8 285
  342. Circle -16777216 true false 60 75 60
  343. Circle -16777216 true false 180 75 60
  344. 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
  345. face neutral
  346. false
  347. 0
  348. Circle -7500403 true true 8 7 285
  349. Circle -16777216 true false 60 75 60
  350. Circle -16777216 true false 180 75 60
  351. Rectangle -16777216 true false 60 195 240 225
  352. face sad
  353. false
  354. 0
  355. Circle -7500403 true true 8 8 285
  356. Circle -16777216 true false 60 75 60
  357. Circle -16777216 true false 180 75 60
  358. 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
  359. fish
  360. false
  361. 0
  362. Polygon -1 true false 44 131 21 87 15 86 0 120 15 150 0 180 13 214 20 212 45 166
  363. Polygon -1 true false 135 195 119 235 95 218 76 210 46 204 60 165
  364. Polygon -1 true false 75 45 83 77 71 103 86 114 166 78 135 60
  365. 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
  366. Circle -16777216 true false 215 106 30
  367. flag
  368. false
  369. 0
  370. Rectangle -7500403 true true 60 15 75 300
  371. Polygon -7500403 true true 90 150 270 90 90 30
  372. Line -7500403 true 75 135 90 135
  373. Line -7500403 true 75 45 90 45
  374. flower
  375. false
  376. 0
  377. Polygon -10899396 true false 135 120 165 165 180 210 180 240 150 300 165 300 195 240 195 195 165 135
  378. Circle -7500403 true true 85 132 38
  379. Circle -7500403 true true 130 147 38
  380. Circle -7500403 true true 192 85 38
  381. Circle -7500403 true true 85 40 38
  382. Circle -7500403 true true 177 40 38
  383. Circle -7500403 true true 177 132 38
  384. Circle -7500403 true true 70 85 38
  385. Circle -7500403 true true 130 25 38
  386. Circle -7500403 true true 96 51 108
  387. Circle -16777216 true false 113 68 74
  388. Polygon -10899396 true false 189 233 219 188 249 173 279 188 234 218
  389. Polygon -10899396 true false 180 255 150 210 105 210 75 240 135 240
  390. house
  391. false
  392. 0
  393. Rectangle -7500403 true true 45 120 255 285
  394. Rectangle -16777216 true false 120 210 180 285
  395. Polygon -7500403 true true 15 120 150 15 285 120
  396. Line -16777216 false 30 120 270 120
  397. leaf
  398. false
  399. 0
  400. 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
  401. Polygon -7500403 true true 135 195 135 240 120 255 105 255 105 285 135 285 165 240 165 195
  402. line
  403. true
  404. 0
  405. Line -7500403 true 150 0 150 300
  406. line half
  407. true
  408. 0
  409. Line -7500403 true 150 0 150 150
  410. pentagon
  411. false
  412. 0
  413. Polygon -7500403 true true 150 15 15 120 60 285 240 285 285 120
  414. person
  415. false
  416. 0
  417. Circle -7500403 true true 110 5 80
  418. 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
  419. Rectangle -7500403 true true 127 79 172 94
  420. Polygon -7500403 true true 195 90 240 150 225 180 165 105
  421. Polygon -7500403 true true 105 90 60 150 75 180 135 105
  422. plant
  423. false
  424. 0
  425. Rectangle -7500403 true true 135 90 165 300
  426. Polygon -7500403 true true 135 255 90 210 45 195 75 255 135 285
  427. Polygon -7500403 true true 165 255 210 210 255 195 225 255 165 285
  428. Polygon -7500403 true true 135 180 90 135 45 120 75 180 135 210
  429. Polygon -7500403 true true 165 180 165 210 225 180 255 120 210 135
  430. Polygon -7500403 true true 135 105 90 60 45 45 75 105 135 135
  431. Polygon -7500403 true true 165 105 165 135 225 105 255 45 210 60
  432. Polygon -7500403 true true 135 90 120 45 150 15 180 45 165 90
  433. sheep
  434. false
  435. 0
  436. Rectangle -7500403 true true 151 225 180 285
  437. Rectangle -7500403 true true 47 225 75 285
  438. Rectangle -7500403 true true 15 75 210 225
  439. Circle -7500403 true true 135 75 150
  440. Circle -16777216 true false 165 76 116
  441. square
  442. false
  443. 0
  444. Rectangle -7500403 true true 30 30 270 270
  445. square 2
  446. false
  447. 0
  448. Rectangle -7500403 true true 30 30 270 270
  449. Rectangle -16777216 true false 60 60 240 240
  450. star
  451. false
  452. 0
  453. Polygon -7500403 true true 151 1 185 108 298 108 207 175 242 282 151 216 59 282 94 175 3 108 116 108
  454. target
  455. false
  456. 0
  457. Circle -7500403 true true 0 0 300
  458. Circle -16777216 true false 30 30 240
  459. Circle -7500403 true true 60 60 180
  460. Circle -16777216 true false 90 90 120
  461. Circle -7500403 true true 120 120 60
  462. tree
  463. false
  464. 0
  465. Circle -7500403 true true 118 3 94
  466. Rectangle -6459832 true false 120 195 180 300
  467. Circle -7500403 true true 65 21 108
  468. Circle -7500403 true true 116 41 127
  469. Circle -7500403 true true 45 90 120
  470. Circle -7500403 true true 104 74 152
  471. triangle
  472. false
  473. 0
  474. Polygon -7500403 true true 150 30 15 255 285 255
  475. triangle 2
  476. false
  477. 0
  478. Polygon -7500403 true true 150 30 15 255 285 255
  479. Polygon -16777216 true false 151 99 225 223 75 224
  480. truck
  481. false
  482. 0
  483. Rectangle -7500403 true true 4 45 195 187
  484. Polygon -7500403 true true 296 193 296 150 259 134 244 104 208 104 207 194
  485. Rectangle -1 true false 195 60 195 105
  486. Polygon -16777216 true false 238 112 252 141 219 141 218 112
  487. Circle -16777216 true false 234 174 42
  488. Rectangle -7500403 true true 181 185 214 194
  489. Circle -16777216 true false 144 174 42
  490. Circle -16777216 true false 24 174 42
  491. Circle -7500403 false true 24 174 42
  492. Circle -7500403 false true 144 174 42
  493. Circle -7500403 false true 234 174 42
  494. turtle
  495. true
  496. 0
  497. Polygon -10899396 true false 215 204 240 233 246 254 228 266 215 252 193 210
  498. Polygon -10899396 true false 195 90 225 75 245 75 260 89 269 108 261 124 240 105 225 105 210 105
  499. Polygon -10899396 true false 105 90 75 75 55 75 40 89 31 108 39 124 60 105 75 105 90 105
  500. Polygon -10899396 true false 132 85 134 64 107 51 108 17 150 2 192 18 192 52 169 65 172 87
  501. Polygon -10899396 true false 85 204 60 233 54 254 72 266 85 252 107 210
  502. Polygon -7500403 true true 119 75 179 75 209 101 224 135 220 225 175 261 128 261 81 224 74 135 88 99
  503. wheel
  504. false
  505. 0
  506. Circle -7500403 true true 3 3 294
  507. Circle -16777216 true false 30 30 240
  508. Line -7500403 true 150 285 150 15
  509. Line -7500403 true 15 150 285 150
  510. Circle -7500403 true true 120 120 60
  511. Line -7500403 true 216 40 79 269
  512. Line -7500403 true 40 84 269 221
  513. Line -7500403 true 40 216 269 79
  514. Line -7500403 true 84 40 221 269
  515. x
  516. false
  517. 0
  518. Polygon -7500403 true true 270 75 225 30 30 225 75 270
  519. Polygon -7500403 true true 30 75 75 30 270 225 225 270
  520. @#$#@#$#@
  521. NetLogo 4.1.3
  522. @#$#@#$#@
  523. @#$#@#$#@
  524. @#$#@#$#@
  525. @#$#@#$#@
  526. @#$#@#$#@
  527. default
  528. 0.0
  529. -0.2 0 1.0 0.0
  530. 0.0 1 1.0 0.0
  531. 0.2 0 1.0 0.0
  532. link direction
  533. true
  534. 0
  535. Line -7500403 true 150 150 90 180
  536. Line -7500403 true 150 150 210 180
  537. @#$#@#$#@
  538. 0
  539. @#$#@#$#@