[2aac52]: examples / notany / run.py Maximize Restore History

Download this file

run.py    40 lines (31 with data), 1.0 kB

 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
# run.py
from __future__ import with_statement
import sys
from pyke import knowledge_engine
from pyke import krb_traceback
engine = knowledge_engine.engine(__file__)
def fc_test():
engine.reset()
try:
engine.activate('fc_notany')
except:
krb_traceback.print_exc()
sys.exit(1)
def bc_test():
engine.reset()
try:
engine.activate('bc_notany')
#with engine.prove_goal(
# 'bc_notany.siblings($sibling1, $sibling2, $_, $_)') \
# as gen1:
# for vars, plan in gen1:
# print "siblings:", vars['sibling1'], vars['sibling2']
with engine.prove_goal('bc_notany.child_with_no_aunt($child)') as gen2:
for vars, plan in gen2:
print vars['child'], "has no aunt"
with engine.prove_goal('bc_notany.child_with_no_uncle($child)') as gen3:
for vars, plan in gen3:
print vars['child'], "has no uncle"
except:
krb_traceback.print_exc()
sys.exit(1)