Пример #1
0
        """
        represent = (self.get_board_size(), self.get_bombs(), self.get_ships())
        return str(represent)

    def play(self):
        """
        The main driver of the Game. Manages the game until completion.
        :return: None
        """
        for ship in self.__ships:
            self.__not_hit_coordinates.extend(ship.coordinates())

        gh.report_legend()

        gh.board_to_string(self.get_board_size(), [], {}, [],
                           deepcopy(self.get_not_hit_coordinates()))

        ships_quantity = len(self.__ships)

        while self.__terminated_ships != ships_quantity:
            self.__play_one_round()
        return None


############################################################
# An example usage of the game
############################################################
if __name__ == "__main__":
    game = Game(5, gh.initialize_ship_list(4, 2))
    game.play()
Пример #2
0
        return str((self.__board_size, self.__bombs, ships_repr))

    def get_coordinates_from_ship_list(self):
        list_coordinates = []
        for ship in self.__ships:
            list_coordinates.extend(ship.coordinates())
        return list_coordinates

    def play(self):
        """
        The main driver of the Game. Manages the game until completion.
        completion.
        :return: None
        """
        gh.report_legend()
        print(
            gh.board_to_string(self.__board_size, [], self.__bombs,
                               self.__hits,
                               self.get_coordinates_from_ship_list()))
        while len(self.__ships) > 0:
            self.__play_one_round()
        gh.report_gameover()


############################################################
# An example usage of the game
############################################################
if __name__ == "__main__":
    game = Game(4, gh.initialize_ship_list(3, 2))
    game.play()