-
Notifications
You must be signed in to change notification settings - Fork 4
/
spaces.metta
34 lines (29 loc) · 1.39 KB
/
spaces.metta
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
29
30
31
32
33
34
;Fully MeTTa-controlled agent demo with atom spaces, featuring NACE + NARS
;Run with:
;python3 main.py world=9 spaces
!(import! &self spaces)
!(bind! &beliefs (new-space))
!(bind! &goals (new-space))
(= (InputInto $space $val) (add-atom $space $val))
;recent metta-nars beliefs and goals:
(= (AddGoalEvent $t $1) (InputInto &goals (GotAtTime $t $1)))
(= (.: $t $1) (InputInto &beliefs (GotAtTime $t $1)))
(= (AddBeliefEvent $t $1) (InputInto &beliefs (GotAtTime $t $1)))
(= (!: $t $1) (InputInto &goals (GotAtTime $t $1)))
(= (Goal $A)
(case (match &goals (GotAtTime $someTime ($A ($Freq $Conf))) ok)
((Empty (AddGoalEvent ($A (1.0 0.90))))
($Else Empty))))
(= (SequenceGoal $A $B)
(case (match &beliefs (GotAtTime $someTime ($A ($Freq $Conf))) ok)
((Empty (Goal $A))
($Else (Goal $B)))))
(= (MakeAndBringCoffee)
(bridgeinput (SequenceGoal (coffee --> (IntSet made)) (table --> (IntSet prepared)))))
(= (Step $t) (superpose ((MakeAndBringCoffee)
;(bridgeinput (AddBeliefEvent ((table --> (IntSet prepared)) (1.0 0.90)))) ;test belief inject
(let* (($space (superpose (&beliefs &goals)))
($Ev (get-atoms $space))
((GotAtTime $t2 $task) $Ev))
(if (> (- $t 50) $t2)
(remove-atom $space $Ev) Empty)))))