def test_generate_move_no_valid_moves() -> None: # No possible moves, chooses first option without rotation second_s = SecondS() second_s.set_color(AllColors[0]) second_s.set_rule_checker(RuleChecker()) b = Board() assert b.initial_move( InitialMove(BoardPosition(1, 0), index_to_tile(34), Port.BottomRight, second_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 = second_s.generate_move(tiles, b.get_board_state()) assert id(r.assert_value()) == id(tiles[0])
def test_incorrect_number_tiles_given() -> None: second_s = SecondS() bs = BoardState() r = second_s.generate_move( [index_to_tile(1), index_to_tile(2), index_to_tile(3)], bs) assert r.is_error() assert r.error() == "Strategy.generate_move given 3 (expected 2)" r2 = second_s.generate_first_move([index_to_tile(1), index_to_tile(2)], bs) assert r2.is_error() assert r2.error() == "Strategy.generate_first_move given 2 (expected 3)"
def test_generate_move_takes_first_tile_no_rotation() -> None: # Test that the first tile is taken when valid second_s = SecondS() second_s.set_color(AllColors[0]) second_s.set_rule_checker(RuleChecker()) b = Board() b.initial_move( InitialMove(BoardPosition(4, 0), index_to_tile(34), Port.BottomRight, second_s.color)) tiles = [index_to_tile(6), index_to_tile(34)] r = second_s.generate_move(tiles, b.get_board_state()) assert r.assert_value().edges == tiles[0].edges