Some improvements and code refactoring (better weighting, etc.)
At some point, the result of battle was always the "wrong" pokemon.
The main problem was this return at end of the battle() function:
return attacker.name if pokemon2.hp["base_stat"] <= 0 else defender.name
Changed to this:
return defender.name if pokemon2.hp["base_stat"] <= 0 else attacker.name
Some improvements and code refactoring (better weighting, etc.) At some point, the result of battle was always the "wrong" pokemon. The main problem was this return at end of the
battle()
function:Changed to this: