Example #1
0
 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))
Example #2
0
    def __init__(self, player_num: int, config: game_config.GameConfig,
                 other_players: List["HumanPlayer"]) -> None:
        self.name = 'No Name'
        self.init_name(player_num, other_players)
        self.board = board.Board(config)
        self.opponents = other_players[:]  # a copy of other players
        self.ships = copy.deepcopy(config.available_ships)
        self.place_ships()

        # make this player the opponent of all the other players
        for opponent in other_players:
            opponent.add_opponent(self)