[495079]: examples / towers_of_hanoi / run.py Maximize Restore History

Download this file

run.py    24 lines (18 with data), 590 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# 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 test(num_disks):
engine.reset()
try:
engine.activate('towers_of_hanoi')
with engine.prove_goal('towers_of_hanoi.solve($num_disks, $moves)',
num_disks=num_disks) \
as gen:
for i, (vars, no_plan) in enumerate(gen):
print "got %d:" % (i + 1), vars['moves']
except:
krb_traceback.print_exc()
sys.exit(1)