manny405 / sapai

Super auto pets engine built with reinforment learning training in mind
MIT License
67 stars 21 forks source link

Multiple hedgehogs - Index out of range error #24

Closed alexdriedger closed 2 years ago

alexdriedger commented 2 years ago

Here's the test to reproduce it

    def test_multiple_hedgehog(self):
        team1 = Team([Pet("fish"), Pet("hedgehog")])
        team2 = Team([Pet("elephant"), Pet("hedgehog")])

        test_battle = Battle(team1, team2)
        test_battle.battle()
Traceback (most recent call last):
  File "C:\Users\aldri\Projects\sapai-fork\tests\test_battles.py", line 86, in test_multiple_hedgehog
    test_battle.battle()
  File "C:\Users\aldri\Projects\sapai-fork\sapai\battle.py", line 76, in battle
    result = self.attack(battle_iter)
  File "C:\Users\aldri\Projects\sapai-fork\sapai\battle.py", line 172, in attack
    battle_phase(
  File "C:\Users\aldri\Projects\sapai-fork\sapai\battle.py", line 391, in battle_phase
    battle_phase_attack_after(battle_obj,phase,teams,pet_priority,phase_dict)
  File "C:\Users\aldri\Projects\sapai-fork\sapai\battle.py", line 705, in battle_phase_attack_after
    t0_pidx = attack_history[0][1][0]
IndexError: list index out of range
manny405 commented 2 years ago

Corrected and test added.

Close when you verify changes no longer lead to this error in the main branch.