Esempio n. 1
0
def test_board_denormalized(bits: int, turn: int) -> None:
    board = Board.from_discs(bits, 0, turn)
    normalized, rotation = board.normalized()
    assert board == normalized.denormalized(rotation)

    board = Board.from_discs(0, bits, turn)
    normalized, rotation = board.normalized()
    assert board == normalized.denormalized(rotation)
Esempio n. 2
0
def test_board_normalized(bits: int, rotation: int, turn: int) -> None:
    board = Board.from_discs(bits, 0, turn)

    assert (
        Board.from_discs(0x000061928C88FF00, 0, turn),
        rotation,
    ) == board.normalized()

    board = Board.from_discs(0, bits, turn)

    assert (
        Board.from_discs(0, 0x000061928C88FF00, turn),
        rotation,
    ) == board.normalized()
Esempio n. 3
0
def test_board_from_discs(me: int, opp: int, turn: bool) -> None:
    board = Board.from_discs(me, opp, turn)
    assert me == board.me
    assert opp == board.opp
    assert turn == board.turn
Esempio n. 4
0
    assert opp == board.opp
    assert turn == board.turn


def test_board_from_xot() -> None:
    board = Board.from_xot()
    assert BLACK == board.turn
    assert 12 == board.count(WHITE) + board.count(BLACK)


@pytest.mark.parametrize(
    ["id_str", "expected_board"],
    (
        ["initial", Board()],
        ["xot", None],
        ["B00000000000000010000000000000002", Board.from_discs(1, 2, BLACK)],
        ["W00000000000000010000000000000002", Board.from_discs(2, 1, WHITE)],
        [
            "Bffffffffffffffffffffffffffffffff",
            Board.from_discs(0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, BLACK),
        ],
    ),
)
def test_board_from_id_ok(id_str: str, expected_board: Board) -> None:
    board = Board.from_id(id_str)

    if id_str == "xot":
        assert BLACK == board.turn
        assert 12 == board.count(WHITE) + board.count(BLACK)
        return