PageRenderTime 53ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/liquidwar6/script/test.scm

#
Scheme | 207 lines | 177 code | 11 blank | 19 comment | 0 complexity | 143583c60eacfe4c3dc4f71b74468767 MD5 | raw file
Possible License(s): GPL-3.0, CC-BY-SA-4.0
  1. ;Liquid War 6 is a unique multiplayer wargame.
  2. ;Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Christian Mauduit <ufoot@ufoot.org>
  3. ;
  4. ;This program is free software; you can redistribute it and/or modify
  5. ;it under the terms of the GNU General Public License as published by
  6. ;the Free Software Foundation, either version 3 of the License, or
  7. ;(at your option) any later version.
  8. ;
  9. ;This program is distributed in the hope that it will be useful,
  10. ;but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. ;GNU General Public License for more details.
  13. ;
  14. ;You should have received a copy of the GNU General Public License
  15. ;along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. ;
  17. ;
  18. ;Liquid War 6 homepage : http://www.gnu.org/software/liquidwar6/
  19. ;Contact author : ufoot@ufoot.org
  20. (load "main.scm") ; load this to catch error in make dist
  21. (define lw6-test-map
  22. (lambda ()
  23. (let (
  24. (the-map (c-lw6ldr-read-relative (c-lw6cfg-unified-get-map-path) "subflower" '() '() 640 480 25 33333))
  25. )
  26. (begin
  27. (display the-map)
  28. (display "\n")))))
  29. (define lw6-test-game-struct
  30. (lambda ()
  31. (let* (
  32. (the-map (c-lw6ldr-read-relative (c-lw6cfg-unified-get-map-path) "subflower" '() '() 640 480 25 33333))
  33. (game-struct (c-lw6ker-build-game-struct the-map))
  34. )
  35. (begin
  36. (display game-struct)
  37. (display "\n")))))
  38. (define lw6-test-game-state
  39. (lambda ()
  40. (let* (
  41. (the-map (c-lw6ldr-read-relative (c-lw6cfg-unified-get-map-path) "subflower" '() '() 640 480 25 33333))
  42. (game-struct (c-lw6ker-build-game-struct the-map))
  43. (game-state (c-lw6ker-build-game-state game-struct))
  44. )
  45. (begin
  46. (display game-state)
  47. (display "\n")))))
  48. (define lw6-test-pilot
  49. (lambda ()
  50. (let* (
  51. (the-map (c-lw6ldr-read-relative (c-lw6cfg-unified-get-map-path) "subflower" '() '() 640 480 25 33333))
  52. (game-struct (c-lw6ker-build-game-struct the-map))
  53. (game-state (c-lw6ker-build-game-state game-struct))
  54. (pilot (c-lw6pil-build-pilot game-state
  55. (c-lw6pil-seq-random-0)
  56. 0))
  57. )
  58. (begin
  59. (c-lw6sys-sleep 1)
  60. (display pilot)
  61. (display "\n")
  62. (c-lw6sys-sleep 1)
  63. ))))
  64. (define lw6-test-bot
  65. (lambda ()
  66. (let* (
  67. (the-map (c-lw6ldr-read-relative (c-lw6cfg-unified-get-map-path) "subflower" '() '() 640 480 25 33333))
  68. (game-struct (c-lw6ker-build-game-struct the-map))
  69. (game-state (c-lw6ker-build-game-state game-struct))
  70. (pilot (c-lw6pil-build-pilot game-state
  71. (c-lw6pil-seq-random-0)
  72. 0))
  73. )
  74. (begin
  75. (c-lw6pil-execute-command game-state "123123123123 1234123412341234 REGISTER" 123123123123)
  76. (c-lw6pil-execute-command game-state "123123123123 1234123412341234 ADD 1234 RED" 123123123123)
  77. (c-lw6pil-execute-command game-state "123123123123 1234123412341234 ADD 2345 GREEN" 123123123123)
  78. (let (
  79. (bot1 (c-lw6bot-new "idiot" game-state pilot 2 "1234" 1.0 100))
  80. (bot2 (c-lw6bot-new "random" game-state pilot 2 "2345" 1.0 100))
  81. )
  82. (begin
  83. (c-lw6ker-do-round game-state)
  84. (display bot1)
  85. (display "\n")
  86. (display (c-lw6bot-next-move bot1))
  87. (display "\n")
  88. (display bot2)
  89. (display "\n")
  90. (display (c-lw6bot-next-move bot2))
  91. (display "\n")
  92. ))))))
  93. (define lw6-test-smobs-gc
  94. (lambda ()
  95. (let (
  96. (menu (c-lw6gui-menu-new "Test" "This is the (usefull) help" "Pop... UP" "Esc" #t))
  97. (game-state (c-lw6ker-build-game-state
  98. (c-lw6ker-build-game-struct
  99. (c-lw6ldr-read-relative (c-lw6cfg-unified-get-map-path) "subflower" '() '() 640 480 25 33333))))
  100. (game-look (c-lw6gui-default-look))
  101. (loader (c-lw6tsk-loader-new 1.5))
  102. )
  103. (begin
  104. (gc)
  105. (display menu)
  106. (display "\n")
  107. (display game-state)
  108. (display "\n")
  109. (display game-look)
  110. (display "\n")
  111. (display loader)
  112. (display "\n")
  113. (gc)
  114. ))))
  115. (define lw6-test-async-load
  116. (lambda ()
  117. (let* (
  118. (loader (c-lw6tsk-loader-new 1.0))
  119. (loaded #f)
  120. )
  121. (begin
  122. (c-lw6tsk-loader-push loader (c-lw6cfg-unified-get-map-path) "subflower" '() '() 640 480 25 33333)
  123. (c-lw6tsk-loader-push loader (c-lw6cfg-unified-get-map-path) "subflower" '() '() 640 480 25 33333)
  124. (c-lw6tsk-loader-push loader (c-lw6cfg-unified-get-map-path) "subflower" '() '() 640 480 25 33333)
  125. (while (not loaded)
  126. (begin
  127. (set! loaded (c-lw6tsk-loader-pop loader))
  128. (c-lw6sys-sleep 0.1)
  129. (display loader)
  130. (display "\n")
  131. #t))))))
  132. (define lw6-test-db
  133. (lambda ()
  134. (begin
  135. (let* (
  136. (db (c-lw6p2p-db-new (c-lw6p2p-db-default-name)))
  137. )
  138. (begin
  139. (display db)
  140. (display "\n")
  141. ))
  142. (gc)
  143. )))
  144. (define lw6-test-node
  145. (lambda ()
  146. (begin
  147. (c-lw6net-init #f)
  148. (let* (
  149. (db (c-lw6p2p-db-new (c-lw6p2p-db-default-name)))
  150. (node (c-lw6p2p-node-new db (list (cons "client-backends" "tcp,udp")
  151. (cons "server-backends" "tcpd,udpd,httpd")
  152. (cons "bind-ip" "0.0.0.0")
  153. (cons "bind-port" 8056)
  154. (cons "public-url" "http://localhost/")
  155. (cons "password" "")
  156. (cons "title" "")
  157. (cons "description" (_ "Dummy test node"))
  158. (cons "bench" 10)
  159. (cons "open-relay" #f)
  160. (cons "known-nodes" "http://ufoot.org:8056/")
  161. (cons "network-reliability" 100)
  162. (cons "trojan" #f)
  163. )))
  164. )
  165. (begin
  166. (display node)
  167. (display "\n")
  168. (display (c-lw6p2p-node-get-id node))
  169. (display "\n")
  170. (c-lw6p2p-node-poll node)
  171. (c-lw6sys-sleep 0.1)
  172. (c-lw6p2p-node-close node)
  173. ))
  174. (c-lw6net-quit)
  175. (gc)
  176. )))
  177. (c-lw6sys-log 2 (_ "testing map"))
  178. (lw6-test-map)
  179. (c-lw6sys-log 2 (_ "testing game struct"))
  180. (lw6-test-game-struct)
  181. (c-lw6sys-log 2 (_ "testing game state"))
  182. (lw6-test-game-state)
  183. (c-lw6sys-log 2 (_ "testing pilot"))
  184. (lw6-test-pilot)
  185. (c-lw6sys-log 2 (_ "testing bot"))
  186. (lw6-test-bot)
  187. (c-lw6sys-log 2 (_ "testing smobs GC, step 1"))
  188. (lw6-test-smobs-gc)
  189. (c-lw6sys-log 2 (_ "testing smobs GC, step 2"))
  190. (lw6-test-smobs-gc)
  191. (c-lw6sys-log 2 (_ "testing async load"))
  192. (lw6-test-async-load)
  193. (c-lw6sys-log 2 (_ "testing db"))
  194. (lw6-test-db)
  195. (c-lw6sys-log 2 (_ "testing node"))
  196. (lw6-test-node)