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 5 months ago

LAMaglan commented 5 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 5 months ago

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

LAMaglan commented 5 months ago

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