Browse Source

supply: report weight/volume usage

raylu 3 weeks ago
parent
commit
29632c949b
1 changed files with 11 additions and 6 deletions
  1. 11 6
      supply.py

+ 11 - 6
supply.py

@@ -39,24 +39,29 @@ 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, int]] = None # pyright: ignore[reportAssignmentType]
+	total_weight_used: float = None # pyright: ignore[reportAssignmentType]
+	total_volume_used: float = None # pyright: ignore[reportAssignmentType]
 	target_days = round(target_days + 0.05, 1)
+	load_more = True
 	while load_more:
 		buys: dict[str, dict[str, int]] = {}
-		total_weight_used = total_volume_used = 0
+		iteration_weight = iteration_volume = 0
 		for planet in planets:
 			buy, weight_used, volume_used = planet.buy_for_target(materials, target_days)
-			total_weight_used += weight_used
-			total_volume_used += volume_used
-			if total_weight_used > args.weight or total_volume_used > args.volume:
+			iteration_weight += weight_used
+			iteration_volume += volume_used
+			if iteration_weight > args.weight or iteration_volume > args.volume:
 				load_more = False
 				break
 			buys[planet.name] = buy
 		if load_more:
 			optimal = buys
+			total_weight_used = iteration_weight
+			total_volume_used = iteration_volume
 		target_days += 0.1
-	print('supply for', round(target_days, 1), 'days')
+	print('supply for', round(target_days, 1), 'days,', end=' ')
+	print(f'consuming {round(total_weight_used, 1)}t and {round(total_volume_used, 1)}㎥') # pyright: ignore[reportPossiblyUnboundVariable]
 
 	for planet in planets:
 		print('\n' + cyan(planet.name))