コード例 #1
0
            elif puzzle.isWall(row_temp, col_temp):
                break
            elif puzzle.arr[row_temp, col_temp] == puzzle.LIGHT_ON:
                count -= 1
            count += 1
            col_temp, row_temp = col_temp + x, row_temp + y
    return count


def findConstraining(puzzle, notAssigned_list):
    if len(notAssigned_list) == 0:
        return []
    winner = []
    max_count = 0
    for row, col in notAssigned_list:
        count = countLightUp(puzzle, row, col)
        if count >= max_count:
            winner = tuple([row, col])
            max_count = count

    return winner


if __name__ == '__main__':
    f = game.read_puzzle_file(fileName=testing_file_name)
    puzzle = game.get_next_puzzle(f, isForward=True)

    while puzzle is not None:
        solvePuzzleH2(puzzle)
        puzzle = game.get_next_puzzle(f, isForward=True)
コード例 #2
0
    'fc.solvePuzzle': fc.solvePuzzle,
    'fc_H1.solvePuzzle': fc_H1.solvePuzzleH1,
    'fc_H2.solvePuzzle': fc_H2.solvePuzzleH2,
    'fc_H3.solvePuzzle': fc_H3.solvePuzzleH3,
    'backtrack.solvePuzzle': bt.solvePuzzle,
    'backtrack_H2.solvePuzzle': bt_H2.solvePuzzleH2
}

file_names = [
    'puzzle_sample/12x12_48W.txt', 'puzzle_sample/12x12_24W.txt',
    'puzzle_sample/12x12_12W.txt'
]

if __name__ == '__main__':
    for fileName in file_names:
        f = game.read_puzzle_file(fileName=fileName)
        puzzle = game.get_next_puzzle(f, isForward=True)

        while puzzle is not None:
            for method in track_methods:
                print('\n/*********************')
                print(method)
                print('*********************/')
                proc = mp.Process(target=track_methods[method],
                                  args=(copy.deepcopy(puzzle), ))
                start_time = time.time()
                proc.start()
                proc.join(timeout=60)
                exec_time = time.time() - start_time
                print("execution time: " + str(exec_time))
                if proc.is_alive():