From 895a4eb0dca0bcd0d7336704c97cf171aa92df53 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Mon, 7 Mar 2022 19:35:19 -0800 Subject: [PATCH] Make flight death chance not impossible. The odds of random.random() returning exactly 1.0 are basically nil, and that was the only way a non-solo flight could lose this. --- game/sim/combat/aircombat.py | 2 +- game/sim/combat/defendingsam.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/game/sim/combat/aircombat.py b/game/sim/combat/aircombat.py index e1a93228..abdb8e48 100644 --- a/game/sim/combat/aircombat.py +++ b/game/sim/combat/aircombat.py @@ -92,7 +92,7 @@ class AirCombat(JoinableCombat): for flight in winner: assert isinstance(flight.state, InCombat) - if random.random() / flight.count >= 0.5: + if random.random() >= 0.5: flight.kill(results, events) else: flight.state.exit_combat() diff --git a/game/sim/combat/defendingsam.py b/game/sim/combat/defendingsam.py index 0ae0619a..9356e376 100644 --- a/game/sim/combat/defendingsam.py +++ b/game/sim/combat/defendingsam.py @@ -39,7 +39,7 @@ class DefendingSam(FrozenCombat): def resolve(self, results: SimulationResults, events: GameUpdateEvents) -> None: assert isinstance(self.flight.state, InCombat) - if random.random() / self.flight.count >= 0.5: + if random.random() >= 0.5: logging.debug(f"Air defense combat auto-resolved with {self.flight} lost") self.flight.kill(results, events) else: