|
|
@@ -151,7 +151,7 @@ def calculate_optimal(planets: typing.Sequence[Planet], materials: typing.Mappin
|
|
|
for ticker, consumption in planet.net_consumption.items():
|
|
|
avail = planet.inventory.get(ticker, 0)
|
|
|
days = avail / consumption
|
|
|
- print(f'{ticker:>3}: {avail:5d} ({consumption:8.2f}/d) {days:4.1f} d', end='')
|
|
|
+ print(f'{ticker:>3}: {avail:5d} ({consumption:8.2f}/d) {days:5.1f} d', end='')
|
|
|
if need := planet_buy.get(ticker): # pyright: ignore[reportOptionalMemberAccess]
|
|
|
if ticker in supply_config.ignore_materials:
|
|
|
print(f' | {need:5.0f} (ignored)')
|
|
|
@@ -254,8 +254,13 @@ class Planet:
|
|
|
for ticker, consumption in self.net_consumption.items():
|
|
|
avail = self.inventory.get(ticker, 0)
|
|
|
days = avail / consumption
|
|
|
+ to_buy = 0
|
|
|
if days < target_days:
|
|
|
- buy[ticker] = math.ceil((target_days - days) * consumption)
|
|
|
+ to_buy = math.ceil((target_days - days) * consumption)
|
|
|
+ if avail + to_buy < 2:
|
|
|
+ to_buy = 2 - avail # always stock at least 2 of everything
|
|
|
+ if to_buy > 0:
|
|
|
+ buy[ticker] = to_buy
|
|
|
return buy
|
|
|
|
|
|
class Material(typing.TypedDict):
|