[41e00e]: examples / towers_of_hanoi / test.py Maximize Restore History

Download this file

test.py    24 lines (18 with data), 609 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# test.py
from __future__ import with_statement
import sys
from pyke import knowledge_engine
from pyke import krb_traceback
engine = knowledge_engine.engine('examples.towers_of_hanoi')
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)