Beispiel #1
0
def test_split_capture_with_successful_measurement_outcome():
    b = simulator(0)
    # Repeat the moves several times because the do_move calls will trigger a
    # measurement.
    for _ in range(10):
        b.with_state(u.squares_to_bitboard(["a1", "c3"]))
        # a1 splits into a2 + a3
        b.do_move(
            move.Move(
                "a1",
                "a2",
                target2="a3",
                move_type=enums.MoveType.SPLIT_JUMP,
                move_variant=enums.MoveVariant.BASIC,
            ))
        # Then a3 tries to capture c3, which requires measuring a3.
        # The provided measurement outcome says that there is a piece on a3
        # after all, so the capture is successful.
        b.do_move(
            move.Move(
                "a3",
                "c3",
                move_type=enums.MoveType.JUMP,
                move_variant=enums.MoveVariant.CAPTURE,
                measurement=1,
            ))
        samples = b.sample(1000)
        # The only possible outcome is successful capture.
        expected = {"c3"}
        for sample in samples:
            assert set(u.bitboard_to_squares(sample)) == expected
Beispiel #2
0
def test_bitboard_to_squares():
    assert u.bitboard_to_squares(257) == ['a1', 'a2']
    assert u.bitboard_to_squares(5) == ['a1', 'c1']
Beispiel #3
0
def test_bitboard_to_squares():
    assert u.bitboard_to_squares(257) == ["a1", "a2"]
    assert u.bitboard_to_squares(5) == ["a1", "c1"]