changed the source code situation to be 2 shooters and 2 movers

This commit is contained in:
Richard Harrington 2013-08-22 14:50:27 -04:00
parent 7d1ac4cfe2
commit 1511a41670
2 changed files with 68 additions and 6 deletions

View File

@ -10,9 +10,10 @@
; TODO: have this source-code-picking be done in requests from the UI
; in the browser, not hard-coded here.
(def progs
(conj (repeat 3 (:moving-to-spot source-programs/programs))
(:shooter source-programs/programs)))
(def progs (concat (vals (select-keys source-programs/programs
[:moving-to-left-and-shooting
:moving-to-top-and-shooting]))
(repeat 2 (:moving-to-spot source-programs/programs))))
(defn add-game
"a function to update the games store agent state.

View File

@ -44,12 +44,13 @@
; the width and height of the arena (in meters).
LOOP
0 TO SPEEDX ; Stop the robot (X).
0 TO SPEEDY ; Stop the robot (Y).
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.
@ -65,7 +66,67 @@
B - Y TO SPEEDY ; Take distance from destination in meters and use
; it to set SPEEDY, which is measured in decimeters/second.
ENDSUB "
:moving-to-left-and-shooting
"
; Note: # means !=
90 TO AIM ; Set the gun to shoot right
15 TO A ; Set the coordinates for the left side.
128 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 "
:moving-to-top-and-shooting
"
; 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