diff --git a/src/robotwar/brain.clj b/src/robotwar/brain.clj index 2583d07..2edce58 100644 --- a/src/robotwar/brain.clj +++ b/src/robotwar/brain.clj @@ -1,4 +1,5 @@ (ns robotwar.brain + (:use [clojure.pprint :only [pprint]]) (:require [robotwar.assembler :as assembler])) (def op-map (into {} (for [op assembler/op-commands] diff --git a/src/robotwar/core.clj b/src/robotwar/core.clj index accf607..daa2512 100644 --- a/src/robotwar/core.clj +++ b/src/robotwar/core.clj @@ -7,7 +7,7 @@ ; this is a hacky place for messing with stuff. (def world - (world/init-world 256.0 256.0 [test-programs/multi-use-program])) + (world/init-world 256.0 256.0 [(:multi-use test-programs/programs)])) (def worlds (world/iterate-worlds world 1.0)) (def robots (:robots world)) diff --git a/test/robotwar/test_programs.clj b/test/robotwar/test_programs.clj index 5357915..05d1de4 100644 --- a/test/robotwar/test_programs.clj +++ b/test/robotwar/test_programs.clj @@ -1,6 +1,7 @@ (ns robotwar.test-programs) -(def multi-use-program +(def programs + {:multi-use " START 0 TO A TEST @@ -11,23 +12,48 @@ INCREMENT A + 1 TO A ENDSUB - 200 TO A ") - -(def index-data-program + 200 TO A " + + :index-data ; to test the INDEX/DATA pair of registers " 300 TO A 1 TO INDEX - DATA TO B") - -(def random-program + DATA TO B" + + :random ; to test the RANDOM register " 1000 TO RANDOM RANDOM TO A RANDOM TO A RANDOM TO A RANDOM TO A - RANDOM TO A ") + RANDOM TO A " -(def speedy-program - " 70 TO SPEEDX - 140 TO SPEEDY ") + :speedy + " 140 TO SPEEDX + 250 TO SPEEDY " + + :moving-to-spot + " + 256 TO RANDOM ; the width and height of the arena + + LOOP + 0 TO SPEEDX + 0 TO SPEEDY + RANDOM TO A + RANDOM TO B + + MOVE + IF A # X GOSUB MOVEX + TO N ; N means no-op + IF B # Y GOSUB MOVEY + IF A = X GOTO LOOP + GOTO MOVE + + MOVEX + A - X TO SPEEDX + ENDSUB + + MOVEY + B - Y TO SPEEDY + ENDSUB "})