dev / templates / bot / src / __NAME__ / policies / registry.cljs
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
;; canon: bot.git src/bot/policies/registry.cljs (ported from src/policies/registry.ts)
;;
;; The policy registry: the seam between the room plumbing and any learned
;; game brains. A game that learns registers a provider object
;; #js {:game :init :forRoom}; __NAME__.rooms asks the registry for an attachment
;; when it joins a game room and wires it in blind — it never knows which
;; games learn. A bot with no learned games simply registers nothing:
;; deleting every provider touches neither this namespace nor __NAME__.rooms.
(ns __NAME__.policies.registry)

(def ^:private providers (js/Map.))

(defn register-policy [^js p]
  (.set providers (.-game p) p)
  js/undefined)

(defn init-policies
  "Process-wide setup (checkpoint stores), once at boot."
  [learning log]
  (.forEach providers (fn [^js p _k] ((.-init p) learning log)))
  js/undefined)

(defn policy-for-room
  "A fresh attachment (#js {:joinOptions :attach}) for one room, or nil."
  [game epsilon data-dir]
  (if-some [^js p (.get providers game)]
    ((.-forRoom p) epsilon data-dir)
    nil))

static mirror of HEAD · about · clone: git clone https://git.ardegazu.ro/dev.git