def test_for_futoshiki_file(filename): print(filename) problem = read_futoshiki_problem(filename, prefix) board = BoardFutoshiki(problem['matrix'], problem['constraints']) solver = Solver(board) results = solver.solve() print(' number of results: ' + str(len(results))) for result in results: print(result) if not check_if_unique(results): global uniqueq unique = False
def get_boards(folder_name): boards = [] for filename in listdir(getcwd() + '/' + folder_name + '/'): if 'futoshiki' in folder_name: problem = read_futoshiki_problem(filename=filename, prefix=getcwd() + '/' + folder_name + '/') board = BoardFutoshiki(matrix=problem['matrix'], constraints=problem['constraints'], name=problem['name']) boards.append(board) elif 'skyscrapper' in folder_name: problem = read_skyscrapper_problem(filename=filename, prefix=getcwd() + '/' + folder_name + '/') board = BoardSkyscrapper(N=problem['N'], constraints=problem['constraints'], name=problem['name']) boards.append(board) else: print('WARNING! there is no such game') return boards
def test_result_of_solving_futoshiki_4_1(self): problem = read_futoshiki_problem('futoshiki_4_1.txt') board = BoardFutoshiki(matrix=problem['matrix'], constraints=problem['constraints']) solver = Solver(board) results = solver.solve()
def test_solving_futoshiki_4_2_doesnt_crash_program(self): problem = read_futoshiki_problem('futoshiki_4_2.txt') board = BoardFutoshiki(matrix=problem['matrix'], constraints=problem['constraints']) # print(board.matrix) solver = Solver(board) results = solver.solve()
def test_read_constraints(self): expected_constraints = [Constraint(x_1=3, y_1=3, x_2=3, y_2=2)] result = read_futoshiki_problem(filename) self.assertListEqual(result['constraints'], expected_constraints)
def test_read_matrix(self): expected_matrix = [[0, 0, 0, 3], [0, 1, 0, 0], [2, 0, 0, 0], [4, 0, 0, 0]] result = read_futoshiki_problem(filename) self.assertEqual(result['matrix'], expected_matrix)
def test_read_N(self): result = read_futoshiki_problem(filename) self.assertEqual(result['N'], 4)