def setUp(self) -> None:
     super().setUp()
     classic_config = config.GameConfig('../configs/classic_game.txt')
     self.classic_board = board.Board(classic_config)
     for row, ship in enumerate(
             sorted(classic_config.available_ships.values())):
         self.classic_board.place_ship(
             ship_placement.ShipPlacement(
                 ship, orientation.Orientation.HORIZONTAL, row, 0))
Exemple #2
0
 def get_ship_placement(self, ship_: ship.Ship):
     while True:
         try:
             orientation_ = self.get_orientation(ship_)
             start_row, start_col = self.get_start_coords(ship_)
         except ValueError as e:
             print(e)
         else:
             return ship_placement.ShipPlacement(ship_, orientation_, start_row, start_col)
Exemple #3
0
 def get_random_ai_ship_placement(self, ship_):
     while True:
         try:
             orientation_ = self.get_ship_orientation(ship_)
             start_row, start_col = self.get_ship_start_coords(
                 ship_, orientation_)
         except ValueError as e:
             pass
         else:
             return ship_placement.ShipPlacement(ship_, orientation_,
                                                 start_row, start_col)