|
@@ -157,14 +157,14 @@ def solve(working, domains, unassigned, count):
|
|
|
# forward checking solver
|
|
|
def forward(start):
|
|
|
working = copy.deepcopy(start) # this is only "filled in values" and 0s
|
|
|
- domains = gen2Domains(start)
|
|
|
+ domains = gen2Domains(working)
|
|
|
# unassigned will be a list of positions we have to fill
|
|
|
unassigned = []
|
|
|
for i in range(0, 9):
|
|
|
for j in range(0, 9):
|
|
|
if (len(domains[i][j]) == 9):
|
|
|
unassigned.append((i, j))
|
|
|
-
|
|
|
+
|
|
|
# forward-checking on pre-assigned values
|
|
|
for i in range(0, 9):
|
|
|
for j in range(0, 9):
|
|
@@ -351,9 +351,9 @@ def main():
|
|
|
for l in board:
|
|
|
board[board.index(l)] = list(map(lambda x: int(x), l.split()))
|
|
|
|
|
|
- avgA += naive(board)
|
|
|
- avgB += forward(board)
|
|
|
- avgC += heuristic(board)
|
|
|
+ avgA += naive(copy.deepcopy(board));print(i, j)
|
|
|
+ avgB += forward(copy.deepcopy(board));print(i, j)
|
|
|
+ avgC += heuristic(copy.deepcopy(board));print(i, j)
|
|
|
|
|
|
averages.append(avgA / 10.0)
|
|
|
bverages.append(avgB / 10.0)
|