|
|
@@ -30,7 +30,7 @@ def main() -> None:
|
|
|
print(planet.name, f'consumes {vol_per_day:.1f}㎥, {weight_per_day:.1f}t per day')
|
|
|
|
|
|
load_more = True
|
|
|
- optimal: dict[str, dict[str, float]] = dict.fromkeys(p.name for p in planets) # pyright: ignore[reportAssignmentType]
|
|
|
+ optimal: dict[str, dict[str, int]] = dict.fromkeys(p.name for p in planets) # pyright: ignore[reportAssignmentType]
|
|
|
target_days = round(target_days + 0.05, 1)
|
|
|
while load_more:
|
|
|
total_weight_used = total_volume_used = 0
|
|
|
@@ -57,8 +57,8 @@ def main() -> None:
|
|
|
print(f' | {need:8.1f}')
|
|
|
else:
|
|
|
print()
|
|
|
-
|
|
|
- combined_buy: dict[str, float] = collections.defaultdict(float)
|
|
|
+
|
|
|
+ combined_buy: dict[str, int] = collections.defaultdict(int)
|
|
|
for buy in optimal.values():
|
|
|
for ticker, amount in buy.items():
|
|
|
combined_buy[ticker] += amount
|
|
|
@@ -71,7 +71,7 @@ def main() -> None:
|
|
|
],
|
|
|
'global': {'name': 'supply ' + ' '.join(planet_names)},
|
|
|
'groups': [{
|
|
|
- 'type': 'Manual', 'name': 'A1', 'materials': {mat: math.ceil(amount) for mat, amount in combined_buy.items()}
|
|
|
+ 'type': 'Manual', 'name': 'A1', 'materials': {mat: amount for mat, amount in combined_buy.items()}
|
|
|
}],
|
|
|
}))
|
|
|
for planet in planets:
|
|
|
@@ -83,7 +83,7 @@ def main() -> None:
|
|
|
],
|
|
|
'global': {'name': 'unload ' + planet.name},
|
|
|
'groups': [{
|
|
|
- 'type': 'Manual', 'name': 'A1', 'materials': {mat: round(amount) for mat, amount in buy.items()}
|
|
|
+ 'type': 'Manual', 'name': 'A1', 'materials': {mat: amount for mat, amount in buy.items()}
|
|
|
}],
|
|
|
}))
|
|
|
|
|
|
@@ -135,16 +135,16 @@ class Planet:
|
|
|
c['net_consumption'] = net
|
|
|
self.net_consumption.append(c)
|
|
|
|
|
|
- def buy_for_target(self, materials: dict[str, Material], target_days: float) -> tuple[dict[str, float], float, float]:
|
|
|
+ def buy_for_target(self, materials: dict[str, Material], target_days: float) -> tuple[dict[str, int], float, float]:
|
|
|
weight_used = volume_used = 0
|
|
|
- buy: dict[str, float] = {}
|
|
|
+ buy: dict[str, int] = {}
|
|
|
for consumption in self.net_consumption:
|
|
|
ticker = consumption['MaterialTicker']
|
|
|
avail = self.inventory.get(ticker, 0)
|
|
|
daily_consumption = consumption['net_consumption']
|
|
|
days = avail / daily_consumption
|
|
|
if days < target_days:
|
|
|
- buy[ticker] = (target_days - days) * daily_consumption
|
|
|
+ buy[ticker] = math.ceil((target_days - days) * daily_consumption)
|
|
|
weight_used += buy[ticker] * materials[ticker]['Weight']
|
|
|
volume_used += buy[ticker] * materials[ticker]['Volume']
|
|
|
return buy, weight_used, volume_used
|