-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bot World Model 220220.py
40 lines (29 loc) · 1.54 KB
/
Bot World Model 220220.py
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
35
36
37
38
39
40
# Basic Autonomous Rover Cognitive Architecture (BARCA)
# (Simple) World Model Test (Beta 0.01)
# www.revelation3.com
# insert 3 entries into the brain's "world model" memory component
# indicating what's been detected by Bot
# index (for ordering purposes), substance detected & timestamp
# setup SWI-Prolog to Python interface
from pyswip import Prolog
prolog = Prolog()
# declare what's been detected and when in a list (for testing)
# generated by Bot's sensors in the Real World!
detected = ["'METAL','2027'", "'GAS','2028'", "'METAL','2029'", "'GAMMA','2033'", "'SMOKE', '2045'"]
# add the above list to the prolog world model plus the software generated index
index = 1
for x in detected:
prolog.assertz("brain(world_model(memory(detect(" + "'" + str(index) + "'," + str(x) + "))))")
index = index + 1
# retrieve the detection list & index from the prolog world model memory & print
print("\n", "World Model Memory of Detection")
print("\n", "Index", "\t", "Substance", "\t", "Time")
print("-----", "\t", "---------", "\t", "----", "\n")
for goal in prolog.query("brain(world_model(memory(detect(Index, Substance, Timestamp))))"):
print(goal["Index"], "\t", goal["Substance"], "\t\t", goal["Timestamp"])
# retrieve just the detected metal & print
print("\n", "World Model Memory of METAL Detection")
print("\n", "Index", "\t", "Time")
print("-----", "\t", "----", "\n")
for goal in prolog.query("brain(world_model(memory(detect(Index, 'METAL', Timestamp))))"):
print(goal["Index"], "\t", goal["Timestamp"])