mirror of
https://github.com/richardharrington/robotwar.git
synced 2024-05-28 23:41:31 +00:00
uncommented and spruced up pprinting convenience functions in core
This commit is contained in:
parent
5892d6ad89
commit
659898494e
|
@ -33,29 +33,23 @@
|
|||
; Very convenient.
|
||||
|
||||
|
||||
;(def pprint-robot
|
||||
; (fn [robot & reg-keys]
|
||||
; (let [{{registers :registers, {instrs :instrs} :obj-code} :brain :as robot} robot
|
||||
; registers-to-print (if reg-keys
|
||||
; (select-keys registers reg-keys)
|
||||
; registers)]
|
||||
; (pprint
|
||||
; (assoc-in
|
||||
; (assoc-in robot [:brain :registers] registers-to-print)
|
||||
; [:brain :obj-code :instrs]
|
||||
; (sort (zipmap (range) instrs)))))))
|
||||
;
|
||||
;(def pprint-robot-in-world
|
||||
; (fn [world robot-idx & reg-keys]
|
||||
; (apply pprint-robot (get-in world [:robots robot-idx]) reg-keys)))
|
||||
;
|
||||
;(def pprint-robot-at-world-tick
|
||||
; (fn [worlds world-tick-idx robot-idx & reg-keys]
|
||||
; (apply pprint-robot-in-world
|
||||
; (world/get-world world-tick-idx robot-idx worlds)
|
||||
; robot-idx
|
||||
; reg-keys)))
|
||||
;
|
||||
;(def ppr pprint-robot)
|
||||
;(def pprw pprint-robot-in-world)
|
||||
;(def pprwt pprint-robot-at-world-tick)
|
||||
(def pprint-robot
|
||||
(fn [robot & reg-keys]
|
||||
(let [{{registers :registers, {instrs :instrs} :obj-code} :brain :as robot} robot
|
||||
registers-to-print (if reg-keys
|
||||
(select-keys registers reg-keys)
|
||||
registers)]
|
||||
(pprint
|
||||
(assoc-in
|
||||
(assoc-in robot [:brain :registers] registers-to-print)
|
||||
[:brain :obj-code :instrs]
|
||||
(sort (zipmap (range) instrs)))))))
|
||||
|
||||
(def pprint-robot-at-combined-world
|
||||
(fn [combined-worlds world-idx robot-idx & reg-keys]
|
||||
(apply pprint-robot
|
||||
(get-in (nth combined-worlds world-idx) [:robots robot-idx])
|
||||
reg-keys)))
|
||||
|
||||
(def ppr pprint-robot)
|
||||
(def pprw pprint-robot-at-combined-world)
|
||||
|
|
Loading…
Reference in New Issue
Block a user