Files
PuGa/puga/planet.py
T
dodoxandClaude Sonnet 5 80b8fa8bf9 Add tools/planet.py: rank planets for a resource with real founding cost
Ranks every planet with a given extraction factor using FIO's bulk
planet data, pricing founding cost straight from FIO's own
BuildRequirements (real environment-extras materials for that specific
planet, not guessed temperature/pressure thresholds - PRUNplanner's own
calculations don't model those either). Takes --from an existing base
to report jump distance via tools/route.py, since pure-factor ranking
alone is misleading: the best-factor planets found for FEO were all
500-2600+ ly away, confirming Vulcan (merely decent factor, same system
as Deimos) was still the right practical pick.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-08 10:42:23 +02:00

28 lines
1.5 KiB
Python

"""Rank planets by extraction factor for a resource, with founding cost (environment extras
from FIO's own BuildRequirements - authoritative, not guessed from temperature/pressure
thresholds, which PRUNplanner's own calculations don't model either)."""
from . import fio
def candidates(resource_ticker: str, min_factor: float = 0.0):
"""All planets with this resource, sorted by factor descending. Each: PlanetNaturalId,
PlanetName, factor, resource_type, plus the raw planet record (temperature/pressure/
gravity/fertility/faction/BuildRequirements/SystemId etc)."""
mats = {m["Ticker"]: m["MaterialId"] for m in fio.materials()}
mid = mats.get(resource_ticker.upper())
if not mid:
raise ValueError(f"unknown material ticker {resource_ticker!r}")
out = []
for p in fio.planets_full():
for r in p.get("Resources", []):
if r["MaterialId"] == mid and r["Factor"] >= min_factor:
out.append({
"natural_id": p["PlanetNaturalId"], "name": p["PlanetName"],
"factor": r["Factor"], "resource_type": r["ResourceType"],
"temperature": p["Temperature"], "pressure": p["Pressure"], "gravity": p["Gravity"],
"fertility": p["Fertility"], "faction": p.get("FactionCode"),
"system_id": p["SystemId"], "build_requirements": p.get("BuildRequirements", []),
})
out.sort(key=lambda x: -x["factor"])
return out