mirror of
https://github.com/richardharrington/robotwar.git
synced 2024-05-28 23:41:31 +00:00
rearranged dependencies so the register names are known only to robot, and passed in function calls to brain
This commit is contained in:
parent
63256d8691
commit
edf835cd02
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user