Пример #1
0
def test_resolve_impossible_moves_2():
    possible_moves = [[((0, 0), 1), ((0, 0), 2), ((1, 1), 1), ((1, 1), 2)],
                      [((0, 0), 1), ((0, 0), 2), ((0, 0), 3), ((1, 1), 1),
                       ((1, 1), 2)]]
    impossible_moves = [((0, 0), [1, 5, 6, 7, 8])]
    moves = resolve_moves(possible_moves, impossible_moves)
    assert len(moves) == 1
Пример #2
0
def test_resolve_game_2():
    board = numpy.loadtxt('games/008.txt')
    possible_moves = []
    impossible_moves = []
    for moveset in sets(board):
        possible_moves.append(find_possible_moves(moveset))
        impossible_moves.append(find_impossible_moves(moveset))

    resolved_moves = resolve_moves(possible_moves)
    assert len(resolved_moves) > 1
Пример #3
0
def play_game(board):
    """ loops through the board trying to make moves """
    again = True
    while again:
        again, possible_moves, impossible_moves = play_single_gaps(board)
        if again:
            continue
        
        # try to find necessary moves using known possible moves
        moves = resolve_moves(possible_moves, impossible_moves)
        if any(moves):
            again = True

        for move in moves:
            make_move(board, move) 
Пример #4
0
def test_resolve_game_1():
    board = numpy.loadtxt('games/008.txt')
    again, possible_moves, impossible_moves = play_single_gaps(board)

    resolved_moves = resolve_moves(possible_moves)
    assert len(resolved_moves) > 1
Пример #5
0
def test_resolve_impossible_moves_1():
    possible_moves = [[((0, 0), 1), ((0, 0), 2)],
                      [((0, 0), 1), ((0, 0), 2), ((0, 0), 3)]]
    impossible_moves = [((0, 0), [2, 3])]
    moves = resolve_moves(possible_moves, impossible_moves)
    assert len(moves) == 1
Пример #6
0
def test_resolve_moves_confounding_0():
    possible_moves = [[((0, 0), 1), ((0, 0), 2), ((1, 1), 1), ((1, 1), 2)],
                      [((0, 0), 1), ((0, 0), 2), ((0, 0), 3), ((1, 1), 1),
                       ((1, 1), 2)]]
    moves = resolve_moves(possible_moves)
    assert len(moves) == 0
Пример #7
0
def test_resolve_moves_2():
    possible_moves = [[((0, 0), 1), ((0, 0), 2)],
                      [((0, 0), 1), ((0, 0), 2), ((0, 0), 3)]]
    moves = resolve_moves(possible_moves)
    assert len(moves) == 0
Пример #8
0
def test_resolve_moves_1():
    possible_moves = [[((0, 0), 1), ((0, 0), 2)], [((0, 0), 1), ((0, 0), 3)]]
    moves = resolve_moves(possible_moves)
    assert len(moves) == 1
    assert moves[0] == ((0, 0), 1)