Exemple #1
0
def test_queen_valid_moves():
    board = Board()
    queen = Queen(1, 3, 'b')
    queen.valid_moves(board)
    actual = queen.move_list
    expected = [[0, 3], [2, 3], [3, 3], [4, 3], [5, 3], [6, 3], [7, 3], [1, 2],
                [1, 1], [1, 0], [1, 4], [1, 5], [1, 6], [1, 7], [0, 2], [0, 4],
                [2, 2], [3, 1], [4, 0], [2, 4], [3, 5], [4, 6], [5, 7]]
    assert actual == expected
Exemple #2
0
def test_queen_attacking():
    board = Board()
    queen = Queen(4, 3, 'w')
    board.board[4][3] = queen
    board.board[5][4] = Pawn(5, 4, 'b')
    board.board[2][3] = Pawn(2, 3, 'b')
    queen.valid_moves(board)
    actual = queen.attack_list
    expected = [[2, 3], [5, 4]]
    assert actual == expected
Exemple #3
0
def test_queen_valid_moves_two():
    board = Board()
    queen = Queen(4, 4, 'b')
    queen.valid_moves(board)
    actual = queen.move_list
    expected = [[3, 4], [2, 4], [1, 4], [0, 4], [5, 4], [6, 4], [7, 4], [4, 3],
                [4, 2], [4, 1], [4, 0], [4, 5], [4, 6], [4, 7], [3, 3], [2, 2],
                [1, 1], [0, 0], [3, 5], [2, 6], [1, 7], [5, 3], [6, 2], [7, 1],
                [5, 5], [6, 6], [7, 7]]
    assert actual == expected
Exemple #4
0
def test_queen_no_moves_after_attacking():
    board = Board()
    queen = Queen(4, 3, 'w')
    board.board[4][3] = queen
    board.board[5][4] = Pawn(5, 4, 'b')
    queen.valid_moves(board)
    actual = queen.move_list
    expected = [[3, 3], [2, 3], [1, 3], [0, 3], [5, 3], [6, 3], [7, 3], [4, 2],
                [4, 1], [4, 0], [4, 4], [4, 5], [4, 6], [4, 7], [3, 2], [2, 1],
                [1, 0], [3, 4], [2, 5], [1, 6], [0, 7], [5, 2], [6, 1], [7, 0]]
    assert actual == expected
Exemple #5
0
def test_psuedo_move():
    board = Board()
    king = King(7, 0, 'w')
    board.board[7][0] = king
    queen = Queen(6, 0, 'b')
    board.board[6][0] = queen
    rook = Rook(5, 0, 'b')
    board.board[5][0] = rook
    queen.valid_moves(board)
    rook.valid_moves(board)
    king.valid_moves(board)

    actual = king.psuedo_move([6, 0], board)
    print('rook attacks', rook.attack_list)
    expected = False
    assert actual == expected
Exemple #6
0
def test_checkmate_true():
    board = Board()
    king = King(7, 0, 'w')
    board.board[7][0] = king
    queen = Queen(6, 0, 'b')
    board.board[6][0] = queen
    rook = Rook(5, 0, 'b')
    board.board[5][0] = rook
    queen.valid_moves(board)
    rook.valid_moves(board)

    print('king position', queen.attack_list)
    king.valid_moves(board)
    actual = board.checkmate_status()
    print('king attacks', king.attack_list)
    print('rook attacks', rook.attack_list)
    expected = True
    assert actual == expected