Ejemplo n.º 1
0
def test_start_moves():
    board = ChessBoard("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1")
    assert board.possible_moves("a2") == ["a3", "a4"]
    assert board.possible_moves("a7") == ["a6", "a5"]
    assert board.possible_moves("a1") == []
    assert board.possible_moves("b1") == ["a3", "c3"]
    assert board.possible_moves("c1") == []
    assert board.possible_moves("d1") == []
Ejemplo n.º 2
0
def test_queen():
    board = ChessBoard("8/8/8/8/2ppp3/2pq1P2/6P1/3p1QP1 w - - 0 1")
    assert board.possible_moves("f1") == ["e1", "d1", "f2", "e2", "d3"]
    assert board.possible_moves("d3") == ["e3", "f3", "d2", "c2", "b1", "e2", "f1"]
Ejemplo n.º 3
0
def test_bishop():
    board = ChessBoard("4p1p1/4pbp1/4P3/7P/8/8/1P6/B7 w - - 0 1")
    assert board.possible_moves("a1") == []
    assert board.possible_moves("f7") == ["e6", "g6", "h5"]
Ejemplo n.º 4
0
def test_knight():
    board = ChessBoard("8/8/8/8/6p1/8/7N/5P2 w - - 0 1")
    assert board.possible_moves("h2") == ["f3", "g4"]
Ejemplo n.º 5
0
def test_rooks():
    board = ChessBoard("4p1p1/4prp1/5P2/8/8/8/p7/RP6 w - - 0 1")
    assert board.possible_moves("a1") == ["a2"]
    assert board.possible_moves("f7") == ["f6", "f8"]
Ejemplo n.º 6
0
def test_pawns():
    board = ChessBoard("8/8/7P/4P3/2p1P3/5pp1/2P2P2/8 w - - 0 1")
    assert board.possible_moves("f2") == ["g3"]
    assert board.possible_moves("h6") == ["h7"]
    assert board.possible_moves("c2") == ["c3"]
    assert board.possible_moves("e4") == []