예제 #1
0
def test_hash():
    board_state = build_board_state('000000000000000000000000000')
    test_game = Game(1, board_state)

    print(hash(test_game))

    d = {test_game: '1'}

    print(d)

    board_state = build_board_state('000000000000000000000000000')
    test_game = Game(1, board_state)

    print(hash(test_game))

    print(test_game in d)
예제 #2
0
def solve_start(depth, recursive, load):
    print(depth, recursive, load)

    start = time.time()
    board_state = build_board_state('000000000000000000000000000')
    test_game = Game(1, board_state)

    print(test_game)

    if recursive:
        solver = SolverRecursive(test_game, depth)

        if load:
            if os.path.isfile('saved.pkl'):
                solver.load('saved.pkl')
    else:
        solver = Solver(test_game, depth)

    result, move, _ = solver.solve(test_game)

    for (_, m, rot) in move:
        test_game = test_game.rotate(rot)
        test_game = test_game.apply_move(m)
        print(test_game)

    if recursive and load:
        solver.save('saved.pkl')

    print(result, move)

    print('Total Time: %.3f' % (time.time() - start))
예제 #3
0
def random_game():
    board_state = build_board_state('000000000000000000000000000')
    test_game = Game(1, board_state)

    print(test_game)
    play = RandomGame(test_game)
    play.play()
예제 #4
0
def solve_two_move():
    board_state = build_board_state('100200000200000000100000100')
    test_game = Game(2, board_state)

    print(test_game)

    solver = Solver(test_game)
    result, move = solver.solve(test_game)
    print(result, move)
예제 #5
0
def solve_pos3(depth):
    board_state = build_board_state('100200000000100000000000000')
    test_game = Game(2, board_state)

    print(test_game)

    solver = Solver(test_game, depth)
    result, move = solver.solve(test_game)
    print(result, move)
예제 #6
0
def solve_pos1(depth, load):
    board_state = build_board_state('100100200000000000000020000')
    test_game = Game(1, board_state)

    print(test_game)

    solver = SolverRecursive(test_game, depth)
    if load:
        solver.load('saved.pkl')
    result, move = solver.solve(test_game)
    print(result, move)