LAMaglan / PokeFightSimulator

A (simple) fight simulator between any two Pokemon using FastAPI with Jinja frontend
0 stars 0 forks source link

Randomize attacker when pokemon speed is the same #69

Closed LAMaglan closed 7 months ago

LAMaglan commented 7 months ago

In the battle_simulator, intially, the attacker is chosen based on who has highest updated_speed:

    attacker, defender = (
        (pokemon1, pokemon2)
        if pokemon1.speed_updated > pokemon2.speed_updated
        else (pokemon2, pokemon1)
    )

However, when the speed is the same, it will bias towards pokemon2. In such cases, it should be random which pokemon becomes the attacker

LAMaglan commented 7 months ago

Although this should be a quick fix, somehow, this can sometimes mean that the attacker is the same across rounds?

LAMaglan commented 7 months ago

The issue seemed to only occur when trying to encapsulate in a function...