示例#1
0
def test_generate_move_no_valid_moves() -> None:
    # No possible moves, chooses second option without rotation
    third_s = ThirdS()
    third_s.set_color(AllColors[0])
    third_s.set_rule_checker(RuleChecker())
    b = Board()
    assert b.initial_move(
        InitialMove(
            BoardPosition(1, 0), index_to_tile(34), Port.BottomRight, third_s.color
        )
    ).is_ok()

    tiles = [
        Tile(
            cast(
                List[Tuple[PortID, PortID]],
                [tuple(Port.all()[i : i + 2]) for i in range(0, len(Port.all()), 2)],
            )
        ),
        Tile(
            cast(
                List[Tuple[PortID, PortID]],
                [tuple(Port.all()[i : i + 2]) for i in range(0, len(Port.all()), 2)],
            )
        ),
    ]
    r = third_s.generate_move(tiles, b.get_board_state())
    assert id(r.assert_value()) == id(tiles[1])
示例#2
0
def test_generate_move_takes_second_tile_no_rotation() -> None:
    # Test that the second tile is taken when valid
    third_s = ThirdS()
    third_s.set_color(AllColors[0])
    third_s.set_rule_checker(RuleChecker())
    b = Board()
    b.initial_move(
        InitialMove(
            BoardPosition(4, 0), index_to_tile(34), Port.BottomRight, third_s.color
        )
    )

    tiles = [index_to_tile(34), index_to_tile(6)]
    r = third_s.generate_move(tiles, b.get_board_state())
    assert r.assert_value().edges == tiles[1].edges
示例#3
0
def test_generate_move_needs_rotation() -> None:
    # Test that the first tile is rotated to a valid rotation when the second tile is invalid
    third_s = ThirdS()
    third_s.set_color(AllColors[0])
    third_s.set_rule_checker(RuleChecker())
    b = Board()
    b.initial_move(
        InitialMove(
            BoardPosition(9, 0), index_to_tile(34), Port.BottomRight, third_s.color
        )
    )

    tiles = [index_to_tile(11), index_to_tile(34)]
    r = third_s.generate_move(tiles, b.get_board_state())
    assert r.assert_value().edges == tiles[0].rotate().edges