Beispiel #1
0
    def gladiatorial_combat(self, player_one: str, player_two: str) -> int:
        """ This method reads and creates an army for each player, say army1
            and army1, sets them in stack formation

        @complexity: Best O(n) and worst O(n)
        """
        FORMATION = 0  # constant
        army_1 = Army()  # creating an instance of Army
        army_1.choose_army(player_one, FORMATION)  # creating player stack

        army_2 = Army()  # creating an instance of Army
        army_2.choose_army(player_two, FORMATION)  # creating player stack

        return self.__conduct_combat(army_1, army_2, FORMATION)
Beispiel #2
0
    def fairer_combat(self, player_one: str, player_two: str) -> int:
        """ Conducts a battle between two armies in queue formation and  whenever a
        fighter survives, it gets appended at the end of the queue and at the end it
        return the winner from the conduct_combat method

        @complexity: Best O(n) and worst O(n)
        """
        FORMATION = 1
        army_1 = Army()  # creating an instance of Army
        army_1.choose_army(player_one, FORMATION)  # creating player stack

        army_2 = Army()  # creating an instance of Army
        army_2.choose_army(player_two, FORMATION)  # creating player stack

        return self.__conduct_combat(army_1, army_2, FORMATION)
Beispiel #3
0
    def gladiatorial_combat(self, player_one: str, player_two: str) -> int:
        '''Sets up two players and creates their desired enemies. Returns the value of the victor. 
        Only uses Stack ADT formation. 
        
        0 - Draw
        1 - Player 1 wins
        2 - Player 2 wins
        :complexity: Best O(1) occurs when the __conduct_combat method returns the winner, due to one army having no fighters.
        Worst O(Army*Life), where Army represents the length of the army with the smallest number of fighters and Life 
        represents the life of each figher, and this occurs when the __conduct_combat method iterates through the entire armies.
        '''
        p1 = Army()
        p1.choose_army(str(player_one), 0)
        p2 = Army()
        p2.choose_army(str(player_two), 0)

        return self.__conduct_combat(p1, p2, 0)