separated source programs out into regular and dev

This commit is contained in:
Richard Harrington 2013-08-24 06:37:49 -04:00
parent 07bb7db5c9
commit d03d64bd6a
3 changed files with 145 additions and 126 deletions

View File

@ -12,7 +12,7 @@
(def progs (def progs
(repeat 3 (:mover source-programs/programs))) (repeat 3 (:mover source-programs/dev-programs)))
(def world (def world
(world/init-world progs)) (world/init-world progs))
(defn combined-worlds [] (defn combined-worlds []

View File

@ -1,137 +1,156 @@
(ns robotwar.source-programs) (ns robotwar.source-programs)
(def programs (def programs
{:multi-use {
" START :speedy
0 TO A "
TEST 140 TO SPEEDX
IF A > 2 GOTO START 250 TO SPEEDY
GOSUB INCREMENT "
GOTO TEST
100 TO A
INCREMENT
A + 1 TO A
ENDSUB
200 TO A "
:index-data :mover
; to test the INDEX/DATA pair of registers "
" 300 TO A ; Note: # means !=
1 TO INDEX
DATA TO B"
:random 360 TO RANDOM
; to test the RANDOM register RANDOM TO AIM ; Set a random direction to aim the gun
" 1000 TO RANDOM
RANDOM TO A 256 TO RANDOM ; All random numbers will now have as their maximum
RANDOM TO A ; the width and height of the arena (in meters).
RANDOM TO A
RANDOM TO A LOOP
RANDOM TO A " 0 TO SPEEDX ; STOP THE ROBOT!
0 TO SPEEDY
RANDOM TO A ; Store a random X-coordinate in the arena.
RANDOM TO B ; Store a random Y-coordinate in the arena.
MOVE
AIM + 5 TO AIM
IF A # X GOSUB MOVEX ; If we're moving in the X direction, recalibrate SPEEDX.
TO N ; N is for no-op. (needed because there's no ELSE command).
IF B # Y GOSUB MOVEY ; If we're moving in the Y direction, recalibrate SPEEDY.
IF A = X GOTO LOOP ; A = X and B = Y, so we've stopped moving, so start over.
GOTO MOVE ; Continue to move.
MOVEX
A - X TO SPEEDX ; Take distance from destination in meters and use
; it to set SPEEDX, which is measured in decimeters/second.
ENDSUB
MOVEY
B - Y TO SPEEDY ; Take distance from destination in meters and use
; it to set SPEEDY, which is measured in decimeters/second.
ENDSUB
"
:speedy :left-shooter
" 140 TO SPEEDX "
250 TO SPEEDY " ; Note: # means !=
:mover
"
; Note: # means !=
360 TO RANDOM
RANDOM TO AIM ; Set a random direction to aim the gun
256 TO RANDOM ; All random numbers will now have as their maximum
; the width and height of the arena (in meters).
LOOP 90 TO AIM ; Set the gun to shoot right
0 TO SPEEDX ; STOP THE ROBOT!
0 TO SPEEDY
RANDOM TO A ; Store a random X-coordinate in the arena.
RANDOM TO B ; Store a random Y-coordinate in the arena.
MOVE 15 TO A ; Set the coordinates for the left side.
AIM + 5 TO AIM 128 TO B
IF A # X GOSUB MOVEX ; If we're moving in the X direction, recalibrate SPEEDX.
TO N ; N is for no-op. (needed because there's no ELSE command). MOVE
IF B # Y GOSUB MOVEY ; If we're moving in the Y direction, recalibrate SPEEDY. IF A # X GOSUB MOVEX ; If we're moving in the X direction, recalibrate SPEEDX.
IF A = X GOTO LOOP ; A = X and B = Y, so we've stopped moving, so start over. TO N ; N is for no-op. (needed because there's no ELSE command).
GOTO MOVE ; Continue to move. IF B # Y GOSUB MOVEY ; If we're moving in the Y direction, recalibrate SPEEDY.
IF A = X GOTO SHOOT ; A = X and B = Y, so we've stopped moving, so shoot.
MOVEX GOTO MOVE ; Continue to move.
A - X TO SPEEDX ; Take distance from destination in meters and use
; it to set SPEEDX, which is measured in decimeters/second. MOVEX
ENDSUB A - X TO SPEEDX ; Take distance from destination in meters and use
; it to set SPEEDX, which is measured in decimeters/second.
ENDSUB
MOVEY
B - Y TO SPEEDY ; Take distance from destination in meters and use
; it to set SPEEDY, which is measured in decimeters/second.
ENDSUB
SHOOT
200 TO SHOT
GOTO MOVE
"
MOVEY :top-shooter
B - Y TO SPEEDY ; Take distance from destination in meters and use "
; it to set SPEEDY, which is measured in decimeters/second. ; Note: # means !=
ENDSUB "
180 TO AIM ; Set the gun to shoot down
128 TO A ; Set the coordinates for the top.
15 TO B
MOVE
IF A # X GOSUB MOVEX ; If we're moving in the X direction, recalibrate SPEEDX.
TO N ; N is for no-op. (needed because there's no ELSE command).
IF B # Y GOSUB MOVEY ; If we're moving in the Y direction, recalibrate SPEEDY.
IF A = X GOTO SHOOT ; A = X and B = Y, so we've stopped moving, so shoot.
GOTO MOVE ; Continue to move.
MOVEX
A - X TO SPEEDX ; Take distance from destination in meters and use
; it to set SPEEDX, which is measured in decimeters/second.
ENDSUB
MOVEY
B - Y TO SPEEDY ; Take distance from destination in meters and use
; it to set SPEEDY, which is measured in decimeters/second.
ENDSUB
SHOOT
200 TO SHOT
GOTO MOVE
"
:shooter
"
90 TO AIM
200 - Y TO S
SHOOT
S TO SHOT
GOTO SHOOT
"
})
:left-shooter (def dev-programs
" (merge
; Note: # means != programs
{
90 TO AIM ; Set the gun to shoot right :multi-use
"
15 TO A ; Set the coordinates for the left side. START
128 TO B 0 TO A
TEST
IF A > 2 GOTO START
GOSUB INCREMENT
GOTO TEST
100 TO A
INCREMENT
A + 1 TO A
ENDSUB
200 TO A
"
MOVE :index-data
IF A # X GOSUB MOVEX ; If we're moving in the X direction, recalibrate SPEEDX. ; to test the INDEX/DATA pair of registers
TO N ; N is for no-op. (needed because there's no ELSE command). "
IF B # Y GOSUB MOVEY ; If we're moving in the Y direction, recalibrate SPEEDY. 300 TO A
IF A = X GOTO SHOOT ; A = X and B = Y, so we've stopped moving, so shoot. 1 TO INDEX
GOTO MOVE ; Continue to move. DATA TO B
"
MOVEX
A - X TO SPEEDX ; Take distance from destination in meters and use
; it to set SPEEDX, which is measured in decimeters/second.
ENDSUB
MOVEY :random
B - Y TO SPEEDY ; Take distance from destination in meters and use ; to test the RANDOM register
; it to set SPEEDY, which is measured in decimeters/second. "
ENDSUB 1000 TO RANDOM
RANDOM TO A
RANDOM TO A
RANDOM TO A
RANDOM TO A
RANDOM TO A
"
SHOOT }))
200 TO SHOT
GOTO MOVE "
:top-shooter
"
; Note: # means !=
180 TO AIM ; Set the gun to shoot down
128 TO A ; Set the coordinates for the top.
15 TO B
MOVE
IF A # X GOSUB MOVEX ; If we're moving in the X direction, recalibrate SPEEDX.
TO N ; N is for no-op. (needed because there's no ELSE command).
IF B # Y GOSUB MOVEY ; If we're moving in the Y direction, recalibrate SPEEDY.
IF A = X GOTO SHOOT ; A = X and B = Y, so we've stopped moving, so shoot.
GOTO MOVE ; Continue to move.
MOVEX
A - X TO SPEEDX ; Take distance from destination in meters and use
; it to set SPEEDX, which is measured in decimeters/second.
ENDSUB
MOVEY
B - Y TO SPEEDY ; Take distance from destination in meters and use
; it to set SPEEDY, which is measured in decimeters/second.
ENDSUB
SHOOT
200 TO SHOT
GOTO MOVE "
:shooter
"
90 TO AIM
200 - Y TO S
SHOOT
S TO SHOT
GOTO SHOOT "
})

View File

@ -7,7 +7,7 @@
[robotwar.source-programs :as source-programs])) [robotwar.source-programs :as source-programs]))
(def initial-world (def initial-world
(world/init-world [(:multi-use source-programs/programs)])) (world/init-world [(:multi-use source-programs/dev-programs)]))
(def combined-worlds (world/build-combined-worlds initial-world)) (def combined-worlds (world/build-combined-worlds initial-world))