rearranged dependencies so the register names are known only to robot, and passed in function calls to brain

This commit is contained in:
Richard Harrington 2013-08-04 22:18:24 -04:00
parent 63256d8691
commit edf835cd02
2 changed files with 4 additions and 6 deletions

View File

@ -1,9 +1,7 @@
(ns robotwar.brain
(:use [clojure.string :only [join]]
[clojure.pprint :only [pprint]])
(:require (robotwar kernel-lexicon
game-lexicon
foundry)))
(:require (robotwar kernel-lexicon foundry)))
(def op-map (into {} (for [op robotwar.kernel-lexicon/op-commands]
[op (case op
@ -29,11 +27,11 @@
"initialize the brain, meaning all the internal state variables that go along
with the robot program when it's running, except for the registers,
which are queried from the robot."
[src-code]
[src-code reg-names]
{:acc 0
:instr-ptr 0
:call-stack []
:program (robotwar.foundry/assemble src-code robotwar.game-lexicon/reg-names)})
:program (robotwar.foundry/assemble src-code reg-names)})
(defn resolve-arg [{arg-val :val arg-type :type} registers labels world]
"resolves an instruction argument to a numeric value

View File

@ -39,7 +39,7 @@
(assoc-in world path-to-val data))
:val 0}})))))
(def brains (map init-brain src-codes))
(def brains (map #(init-brain % robotwar.game-lexicon/reg-names) src-codes))
(def robots (vec (map (fn [idx brain robot-registers]
{:idx idx