Esempio n. 1
0
def test_all_possible_moves():
    board = ChessBoard("8/7R/6R1/8/8/4K3/7k/8 w - - 0 1")
    assert board.all_moves("b") == {}
    board = ChessBoard("8/7R/8/8/8/4K1R1/7k/8 w - - 0 1")
    assert board.all_moves("b") == {"h2": ["g3"]}
    board = ChessBoard("8/7R/8/3K4/8/1p4R1/2b4k/8 w - - 0 1")
    assert board.all_moves("b") == {"c2": ["h7"], "h2": ["g3"]}
Esempio n. 2
0
def test_move():
    board = ChessBoard("1R6/6R1/8/3K4/8/1p6/2b4k/8 w - - 0 1")
    board.move("g7", "f7")
    assert board.all_moves("b")["h2"] == ["g1", "g2", "g3", "h1", "h3"]
    board = ChessBoard("1R6/6R1/8/3K4/8/1p6/2b4k/8 w - - 0 1")
    board.move("b8", "b3")
    board.move("c2", "b3")
    assert board.pieces["b"] == ["b3", "h2"]
    board = ChessBoard("1R6/6R1/8/3K4/8/1p6/2b4k/8 w - - 0 1")
    board.move("b8", "h8")
    assert board.check["b"]