3402
3402
</td><td class="codes"><pre class="brush: clojure">(defn sort-commutative
3403
3403
[conclusions]
3404
3404
(if (coll? conclusions)
3405
- (let [f (first conclusions)]
3406
- (if (commutative-ops f)
3407
- (vec (conj (sort-by hash (drop 1 conclusions)) f))
3408
- conclusions))
3405
+ (if (= (first conclusions) '--)
3406
+ ['-- (sort-commutative (second conclusions))]
3407
+ (let [f (first conclusions)]
3408
+ (if (commutative-ops f)
3409
+ (vec (conj (sort-by hash (drop 1 conclusions)) f))
3410
+ conclusions)))
3409
3411
conclusions))</pre></td></tr><tr><td class="docs"><p>the union set operation for extensional and intensional sets</p>
3410
3412
3411
3413
<p>https://gist.github.com/TonyLo1/a3f8e05458c5e90c2e72</p>
@@ -4201,7 +4203,7 @@ <h2></h2>
4201
4203
[nal.deriver.key-path :refer [mall-paths all-paths mpath-invariants
4202
4204
path-with-max-level]]
4203
4205
[nal.deriver.rules :refer [rule]]
4204
- [nal.deriver.normalization :refer [commutative-ops]]
4206
+ [nal.deriver.normalization :refer [commutative-ops sort-commutative ]]
4205
4207
[clojure.set :as set]
4206
4208
[nal.term_utils :refer :all]
4207
4209
[clojure.core.memoize :refer [lru]]
@@ -4213,17 +4215,39 @@ <h2></h2>
4213
4215
(case (count matchers)
4214
4216
0 (constantly [])
4215
4217
1 (first matchers)
4216
- (fn [t1 t2] (mapcat #(% t1 t2) matchers)))))</pre></td></tr><tr><td class="docs"><p>generate conclusions not taking commutative subterms of premises into account</p>
4218
+ (fn [t1 t2] (mapcat #(% t1 t2) matchers)))))</pre></td></tr><tr><td class="docs">
4217
4219
</td><td class="codes"><pre class="brush: clojure">#_(def mget-matcher (memoize get-matcher))
4218
4220
(def mget-matcher (lru get-matcher :lru/threshold 50))
4219
4221
#_(def mget-matcher get-matcher)
4220
4222
#_(def mpath (memoize path-with-max-level))
4221
4223
(def mpath (lru path-with-max-level :lru/threshold 50))
4222
4224
#_(def mpath path-with-max-level)
4223
- (defn generate-conclusions-no-commutativity
4225
+ (defn parallel-conj [term]
4226
+ (and (coll? term)
4227
+ (= (first term) '&|)))</pre></td></tr><tr><td class="docs">
4228
+ </td><td class="codes"><pre class="brush: clojure">(defn sequ-conj [term]
4229
+ (and (coll? term)
4230
+ (= (first term) 'seq-conj)))</pre></td></tr><tr><td class="docs">
4231
+ </td><td class="codes"><pre class="brush: clojure">(defn parallel-conj-reduce [term layer]
4232
+ term
4233
+ (if (parallel-conj term)
4234
+ (let [reduced (apply concat
4235
+ (for [x term]
4236
+ (if (parallel-conj x)
4237
+ (parallel-conj-reduce x (inc layer))
4238
+ (if (= x '&|)
4239
+ []
4240
+ [x]))))]
4241
+ (if (= layer 0)
4242
+ (vec (conj reduced '&|))
4243
+ (vec reduced)))
4244
+ term))</pre></td></tr><tr><td class="docs"><p>generate conclusions not taking commutative subterms of premises into account</p>
4245
+ </td><td class="codes"><pre class="brush: clojure">(defn generate-conclusions-no-commutativity
4224
4246
[rules {p1 :statement :as t1} {p2 :statement :as t2}]
4225
- (let [matcher (mget-matcher rules (mpath p1) (mpath p2))]
4226
- (matcher t1 t2)))</pre></td></tr><tr><td class="docs"><p>USE COUNTER (global seed, for making testcased deterministic</p>
4247
+ (let [matcher (mget-matcher rules (mpath p1) (mpath p2))
4248
+ result (set (matcher t1 t2))]
4249
+ (for [z result]
4250
+ (assoc z :statement (sort-commutative (parallel-conj-reduce (:statement z) 0))))))</pre></td></tr><tr><td class="docs"><p>USE COUNTER (global seed, for making testcased deterministic</p>
4227
4251
</td><td class="codes"><pre class="brush: clojure">(def use-counter (ref 0))</pre></td></tr><tr><td class="docs">
4228
4252
</td><td class="codes"><pre class="brush: clojure">(defn use-counter-reset []
4229
4253
(do
@@ -4288,6 +4312,10 @@ <h2></h2>
4288
4312
#_(some #(= % (first term)) '[--> <-> ==> pred-impl retro-impl
4289
4313
=|> <=> </> <|>
4290
4314
-- || conj seq-conj &|])
4315
+ ;temporal copula only allowed once
4316
+ (<= (count (filter '#{==> pred-impl retro-impl
4317
+ =|> <=> </> <|>} (flatten term)))
4318
+ 1)
4291
4319
;inheritance and Similarity can't have independent vars
4292
4320
(not (and (coll? term)
4293
4321
(some #(= % (first term)) '[--> <->])
@@ -5836,10 +5864,10 @@ <h2></h2>
5836
5864
</td><td class="codes"><pre class="brush: clojure">(def inverse-decay-rate 10) ; forgetting adjustment rate for concepts e^-lt where l = (1.0 - durabiity) / decay-rate</pre></td></tr><tr><td class="docs">
5837
5865
</td><td class="codes"><pre class="brush: clojure">(def system-tick-interval-slow 136)
5838
5866
(def inference-tick-interval-slow 100)
5839
- (def system-tick-interval-medium 50 )
5840
- (def inference-tick-interval-medium 25 )
5841
- (def system-tick-interval-fast 20 )
5842
- (def inference-tick-interval-fast 10 )
5867
+ (def system-tick-interval-medium 60 )
5868
+ (def inference-tick-interval-medium 30 )
5869
+ (def system-tick-interval-fast 30 )
5870
+ (def inference-tick-interval-fast 15 )
5843
5871
(def system-tick-interval (atom system-tick-interval-medium)) ;make big enough</pre></td></tr><tr><td class="docs"><p>make big enough</p>
5844
5872
</td><td class="codes"><pre class="brush: clojure">(def inference-tick-interval (atom inference-tick-interval-medium))
5845
5873
(def anticipation-scale-dependent-tolerance 4.0) ;has to be 4 since interval rounding has to agree with time measurement in 2-power</pre></td></tr><tr><td class="docs"><p>has to be 4 since interval rounding has to agree with time measurement in 2-power</p>
@@ -8788,32 +8816,34 @@ <h2></h2>
8788
8816
[gui.gui-utils :refer [invert-comp]]
8789
8817
[narjure.global-atoms :refer :all]
8790
8818
[narjure.core :as nar]
8819
+ [narjure.defaults :refer [max-term-complexity]]
8791
8820
[narjure.sensorimotor :refer :all])
8792
8821
(:gen-class))</pre></td></tr><tr><td class="docs">
8793
8822
</td><td class="codes"><pre class="brush: clojure">(def py (atom 280))
8794
8823
(def direction (atom 0))
8795
- (def barheight 50 )
8824
+ (def barheight 125 )
8796
8825
(def fieldmax 760)
8797
8826
(def fieldmin 20)</pre></td></tr><tr><td class="docs">
8798
8827
</td><td class="codes"><pre class="brush: clojure">(defn with-print [x]
8799
8828
#_(println (str x))
8800
8829
x)</pre></td></tr><tr><td class="docs"><p>Registers the operations</p>
8801
8830
</td><td class="codes"><pre class="brush: clojure">(defn setup-pong
8802
8831
[]
8832
+ (reset! max-term-complexity 21)
8803
8833
(nars-input-narsese "<ballpos --> [equal]>! :|:")
8804
8834
(q/frame-rate 100)
8805
8835
(nars-register-operation 'op_up (fn [args operationgoal]
8806
8836
(do
8807
8837
(when (= (:source operationgoal) :derived)
8808
8838
#_(println "system decided up"))
8809
8839
(reset! direction -1)
8810
- true #_ (with-print (not= @py fieldmin)))))
8840
+ (with-print (not= @py fieldmin)))))
8811
8841
(nars-register-operation 'op_down (fn [args operationgoal]
8812
8842
(do
8813
8843
(when (= (:source operationgoal) :derived)
8814
8844
#_(println "system decided down"))
8815
8845
(reset! direction 1)
8816
- true #_ (with-print (not= @py (- fieldmax barheight (- fieldmin)))))))
8846
+ (with-print (not= @py (- fieldmax barheight (- fieldmin)))))))
8817
8847
(merge hnav/states {:ball-px 380
8818
8848
:ball-py 400
8819
8849
:direction-x 1
@@ -8836,7 +8866,7 @@ <h2></h2>
8836
8866
" below truth " (vec (:truth (lense-max-statement-confidence-projected-to-now '[--> ballpos [int-set below]] :belief :event)))
8837
8867
" equal truth " (vec (:truth (lense-max-statement-confidence-projected-to-now '[--> ballpos [int-set equal]] :belief :event)))))
8838
8868
(nars-input-narsese "<ballpos --> [equal]>! :|:"))
8839
- (when (= (mod (:iteration state) 250 ) 1)
8869
+ (when (= (mod (:iteration state) 125 ) 1)
8840
8870
(println "rand action")
8841
8871
(nars-input-narsese (str (rand-nth ["<(*,{SELF}) --> op_up>! :|:"
8842
8872
"<(*,{SELF}) --> op_down>! :|:"
@@ -8899,8 +8929,8 @@ <h2></h2>
8899
8929
(let [kset-x (+ 0.6 (/ (Math/random) 2.0))
8900
8930
kset-y (+ 0.6 (/ (Math/random) 2.0))
8901
8931
state2 (assoc state
8902
- :ball-px #_(:ball-px state) (+ (:ball-px state) (* (:direction-x state) 1 3 ))
8903
- :ball-py #_(:ball-py state) (+ (:ball-py state) (* (:direction-y state) 1 3 )))
8932
+ :ball-px #_(:ball-px state) (+ (:ball-px state) (* (:direction-x state) 1 1 ))
8933
+ :ball-py #_(:ball-py state) (+ (:ball-py state) (* (:direction-y state) 1 1 )))
8904
8934
state3 (if (>= (:ball-px state2) ;collided on right wall
8905
8935
fieldmax)
8906
8936
(assoc state2 :direction-x (- kset-x))
0 commit comments