manny405 / sapai

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

EachFriend faint triggers activated by enemy faints as well #85

Closed michaelgtuttle closed 2 years ago

michaelgtuttle commented 2 years ago

Enemy faints appear to be triggering the faint abilities of sharks and flies. Below test causes a zombie fly to spawn after enemy otter faints:

from sapai.pets import Pet
from sapai.teams import Team
from sapai.battle import Battle

team0 = Team(["fly"])
team1 = Team(["otter", "shark"])

battle = Battle(team0,team1)
winner = battle.battle()
for key, value in battle.battle_history.items():
    print(f'{key}')
    print(f'{value}')
print(winner)

This test causes an error as sharks try to apply feint triggers

from sapai.pets import Pet
from sapai.teams import Team
from sapai.battle import Battle

team0 = Team(["shark"])
team1 = Team(["shark"])

battle = Battle(team0,team1)
winner = battle.battle()
michaelgtuttle commented 2 years ago

should be solvable by adding the check if self.team != trigger.team: in the pets faint trigger

manny405 commented 2 years ago

This has been fixed in the the newest branch loop_effect_queue.

For fly case you can see tests for behavior here: https://github.com/manny405/sapai/blob/d03f7a69d0fcc1ef9ae4f403611855e29e829eaf/tests/test_effect_queue.py#L117

For shark case you can see tests for behavior here: https://github.com/manny405/sapai/blob/d03f7a69d0fcc1ef9ae4f403611855e29e829eaf/tests/test_effect_queue.py#L164

I am still working on some final test cases for #83. If you are interested in contributing, the remaining test cases start here: https://github.com/manny405/sapai/blob/d03f7a69d0fcc1ef9ae4f403611855e29e829eaf/tests/test_effect_queue.py#L479.