Spaces:
Sleeping
Sleeping
adityaverma977 commited on
Commit ·
d1adb89
1
Parent(s): ac45880
Tune fire extinguishing: inverse scaling so 2 agents = fast game (90s), more agents = slower game (110s+)
Browse files- backend/app/simulation.py +13 -5
backend/app/simulation.py
CHANGED
|
@@ -19,14 +19,18 @@ from . import groq_client
|
|
| 19 |
from . import movement
|
| 20 |
|
| 21 |
FIRE_GROWTH_RATE = 1.0 # radius growth per tick
|
| 22 |
-
FIRE_INTENSITY_GROWTH =
|
| 23 |
-
BASE_EXTINGUISH_RATE =
|
| 24 |
-
MIN_EXTINGUISH_RATE =
|
| 25 |
-
MAX_EXTINGUISH_RATE =
|
| 26 |
TICK_INTERVAL_SECONDS = 3
|
| 27 |
WATER_PICKUP_RANGE = 40
|
| 28 |
EXTINGUISH_RANGE = 45
|
| 29 |
FIRE_SAFE_BUFFER = 10
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
class SimulationEngine:
|
| 32 |
def __init__(self, state: SimulationState) -> None:
|
|
@@ -267,7 +271,11 @@ class SimulationEngine:
|
|
| 267 |
|
| 268 |
if agents_with_water:
|
| 269 |
living_count = len([a for a in agents if a.alive]) or 1
|
| 270 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 271 |
per_agent_rate = BASE_EXTINGUISH_RATE * scale
|
| 272 |
per_agent_rate = max(MIN_EXTINGUISH_RATE, min(MAX_EXTINGUISH_RATE, per_agent_rate))
|
| 273 |
reduction = len(agents_with_water) * per_agent_rate
|
|
|
|
| 19 |
from . import movement
|
| 20 |
|
| 21 |
FIRE_GROWTH_RATE = 1.0 # radius growth per tick
|
| 22 |
+
FIRE_INTENSITY_GROWTH = 1.8 # intensity per tick (faster fire spread for urgency)
|
| 23 |
+
BASE_EXTINGUISH_RATE = 28.0 # baseline intensity reduction per agent
|
| 24 |
+
MIN_EXTINGUISH_RATE = 15.0
|
| 25 |
+
MAX_EXTINGUISH_RATE = 40.0
|
| 26 |
TICK_INTERVAL_SECONDS = 3
|
| 27 |
WATER_PICKUP_RANGE = 40
|
| 28 |
EXTINGUISH_RANGE = 45
|
| 29 |
FIRE_SAFE_BUFFER = 10
|
| 30 |
+
# Target game duration: 90-110 seconds (30-37 ticks)
|
| 31 |
+
# Scaling: fewer agents = faster extinguish (shorter game)
|
| 32 |
+
# more agents = slower extinguish (longer game)
|
| 33 |
+
# scale = (max_agents + 1) / (num_agents + 2) ensures inverse relationship
|
| 34 |
|
| 35 |
class SimulationEngine:
|
| 36 |
def __init__(self, state: SimulationState) -> None:
|
|
|
|
| 271 |
|
| 272 |
if agents_with_water:
|
| 273 |
living_count = len([a for a in agents if a.alive]) or 1
|
| 274 |
+
# Inverse scaling: fewer agents = higher drop rate (shorter game)
|
| 275 |
+
# more agents = lower drop rate (longer game)
|
| 276 |
+
# scale = (6 + 1) / (living_count + 2) ensures fewer agents get faster extinguish
|
| 277 |
+
scale = (7.0) / (living_count + 2.0)
|
| 278 |
+
scale = max(0.5, min(2.5, scale))
|
| 279 |
per_agent_rate = BASE_EXTINGUISH_RATE * scale
|
| 280 |
per_agent_rate = max(MIN_EXTINGUISH_RATE, min(MAX_EXTINGUISH_RATE, per_agent_rate))
|
| 281 |
reduction = len(agents_with_water) * per_agent_rate
|