-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtenner_sample_run.py
56 lines (48 loc) · 1.73 KB
/
tenner_sample_run.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from tenner_csp import *
from propagators import *
import ast, sys
b1 = ([[-1, 0, 1,-1, 9,-1,-1, 5,-1, 2],
[-1, 7,-1,-1,-1, 6, 1,-1,-1,-1],
[-1,-1,-1, 8,-1,-1,-1,-1,-1, 9],
[ 6,-1, 4,-1,-1,-1,-1, 7,-1,-1],
[-1, 1,-1, 3,-1,-1, 5, 8, 2,-1]],
[29,16,18,21,24,24,21,28,17,27])
b2 = ([[6, -1, 1, 5, 7, -1, -1, -1, 3, -1],
[-1, 9, 7, -1, -1, 2, 1, -1, -1, -1],
[-1, -1, -1, -1, -1, 0, -1, -1, -1, 1],
[-1, 9, -1, 0, 7, -1, 3, 5, 4, -1],
[6, -1, -1, 5, -1, 0, -1, -1, -1, -1],],
[21, 26, 21, 21, 29, 10, 28, 26, 21, 22])
b3 = ([[-1,9,5,-1,6,-1,-1,-1,-1,0],
[6,-1,-1,1,-1,-1,0,-1,-1,8],
[-1,0,8,-1,-1,-1,1,5,-1,6],
[-1,-1,-1,-1,-1,6,-1,-1,2,-1],
[-1,-1,-1,2,1,8,-1,0,3,4],
[-1,-1,0,9,6,3,-1,-1,-1,-1],
[1,2,3,4,-1,9,8,-1,-1,-1],
[0,-1,8,-1,6,-1,-1,-1,4,5],],
[31,44,36,42,32,36,34,37,37,31])
def print_tenner_soln(var_array):
for row in var_array:
print([var.get_assigned_value() for var in row])
if __name__ == "__main__":
for b in [b1, b2]:
print("Solving board:")
for row in b[0]:
print(row)
print("Using Model 1")
csp, var_array = tenner_csp_model_1(b)
solver = BT(csp)
print("=======================================================")
print("FC")
solver.bt_search(prop_FC)
print("Solution")
print_tenner_soln(var_array)
print("Using Model 2")
csp, var_array = tenner_csp_model_2(b)
solver = BT(csp)
print("=======================================================")
print("GAC")
solver.bt_search(prop_GAC)
print("Solution")
print_tenner_soln(var_array)