checkpoint

This commit is contained in:
2025-11-09 17:40:11 +00:00
parent f9e1ad0768
commit 9096d38f78
4 changed files with 198 additions and 11 deletions

View File

@@ -5,6 +5,7 @@
<w>callanite</w>
<w>caterium</w>
<w>heatsink</w>
<w>kyalite</w>
<w>larrussite</w>
<w>quickwire</w>
<w>siterite</w>

25
main.py
View File

@@ -50,6 +50,7 @@ class ProductionChain:
self.excess: Dict[Items, float] = defaultdict(float)
self.byproduct: Dict[Items, float] = defaultdict(float)
self.preferred_recipes = preferred_recipes or {}
self.preferred_recipes[Items.Steam] = Recipes.SteamMk1.value
def get_recipe(self, item: Items) -> Optional[Recipe]:
if item in self.preferred_recipes:
@@ -98,6 +99,7 @@ class ProductionChain:
continue
levels = []
for out, quantity in recipe.outputs.items():
if out in demand:
target_quantity = demand[out] - production[out]
@@ -365,6 +367,27 @@ def index():
"building": "",
"rate": target_rates_by_item[item_name],
})
# If there is excess of this item, show it as a destination
if item_name in excess and excess[item_name] > 0:
dests.append({
"recipe": f"Excess: {item_name}",
"building": "",
"rate": excess[item_name],
})
# Also list byproducts produced by this step's recipe at the computed level
# Find this step's recipe and level to compute byproduct rates
rec_obj = prod_chain.recipe_name_to_obj.get(s["recipe"]) if hasattr(prod_chain, "recipe_name_to_obj") else None
if rec_obj is not None:
# Find buildings_float for this step (already stored on s)
lvl = s.get("buildings_float", 0.0)
for byp_item, per_building in rec_obj.byproducts.items():
rate = lvl * per_building
if rate > 0:
dests.append({
"recipe": f"Byproduct: {byp_item.value.name}",
"building": "",
"rate": rate,
})
# Sort destinations by descending rate for display
dests.sort(key=lambda x: x["rate"], reverse=True)
s["destinations"] = dests
@@ -457,4 +480,4 @@ if __name__ == "__main__":
# For local dev: python main.py
app.run(host="0.0.0.0", port=5000, debug=True)
# prod_chain = ProductionChain()
# prod_chain.compute_chain({Items.CateriumHeatsink: 10.0})
# prod_chain.compute_chain({Items.SteelBeam: 3.0})

169
plus.py
View File

@@ -15,6 +15,7 @@ class Machines(Enum):
FlexibleBlastFurnace = Machine(name="Flexible Blast Furnace")
Reformer = Machine(name="Reformer")
WetWasher = Machine(name="Wet Washer")
BoilerMk1 = Machine(name="Boiler Mk1")
class Items(Enum):
@@ -88,6 +89,21 @@ class Items(Enum):
ColdSlag = Item(name="Cold Slag")
FanBlades = Item(name="Fan Blades")
TailingsSlurry = Item(name="Tailings Slurry")
CarbonPowder = Item(name="Carbon Powder")
Coal = Item(name="Coal")
MoltenSteel = Item(name="Molten Steel")
FlueGas = Item(name="Flue Gas")
SteelIngot = Item(name="Steel Ingot")
Air = Item(name="Air")
SteelBeam = Item(name="Steel Beam")
SteelPipe = Item(name="Steel Pipe")
SteelBolt = Item(name="Steel Bolt")
SteelRod = Item(name="Steel Rod")
Stator = Item(name="Stator")
Kyalite = Item(name="Kyalite")
Salt = Item(name="Salt")
Diamonds = Item(name="Diamonds")
QuartzCrystal = Item(name="Quartz Crystal")
class RawResources(Enum):
Water = Items.Water
@@ -95,6 +111,9 @@ class RawResources(Enum):
LarrussiteOre = Items.LarrussiteOre
CallaniteOre = Items.CallaniteOre
AuroviteOre = Items.AuroviteOre
Kyalite = Items.Kyalite
Coal = Items.Coal
Air = Items.Air
class Recipe(BaseModel):
@@ -122,9 +141,9 @@ class Recipes(Enum):
building=Machines.Crusher,
outputs={
Items.CrushedLarrussite: 40.0,
Items.CrushedGangue: 20.0,
},
inputs={Items.LarrussiteOre: 60.0},
byproducts={Items.CrushedGangue: 20.0,}
)
CrushedCallanite = Recipe(
name="Crushed Callanite",
@@ -144,6 +163,15 @@ class Recipes(Enum):
},
inputs={Items.AuroviteOre: 60.0},
)
CrushedSilica = Recipe(
name="Crushed Silica",
building=Machines.Crusher,
outputs={
Items.Silica: 60.0,
Items.Sand: 40.0,
},
inputs={Items.Kyalite: 60.0},
)
# - Crushing Powders
CoarseSand = Recipe(
name="Coarse Sand",
@@ -161,7 +189,14 @@ class Recipes(Enum):
},
inputs={Items.CrushedMagnesium: 80.0},
)
CarbonPowder = Recipe(
name="Carbon Powder",
building=Machines.Crusher,
outputs={
Items.CarbonPowder: 40.0
},
inputs={Items.Coal: 80.0},
)
# Sorter
# - Simple Sorting
CrushedIron = Recipe(
@@ -190,9 +225,11 @@ class Recipes(Enum):
outputs={
Items.CrushedZinc: 96.0,
Items.Sand: 48.0,
Items.CrushedGangue: 60.0,
},
inputs={Items.CrushedLarrussite: 120.0},
byproducts={
Items.CrushedGangue: 60.0,
}
)
CrushedCaterium = Recipe(
name="Crushed Caterium",
@@ -204,6 +241,30 @@ class Recipes(Enum):
},
inputs={Items.CrushedAurovite: 120.0},
)
QuartzCrystal = Recipe(
name="Quartz Crystal",
building=Machines.Sorter,
outputs={
Items.QuartzCrystal: 100.0,
Items.Salt: 40.0,
Items.Sand: 40.0,
},
inputs={Items.Kyalite: 120.0},
)
# - Advanced Sorting
SaltKyalite = Recipe(
name="Salt (Kyalite)",
building=Machines.Sorter,
outputs={
Items.Salt: 90.0,
Items.Silica: 45.0,
Items.Sand: 30.0,
},
inputs={
Items.Kyalite: 120.0,
Items.Water: 45.0,
},
)
# Smelter
# - smelting
IronIngot = Recipe(
@@ -411,6 +472,18 @@ class Recipes(Enum):
outputs={Items.BrassPlates: 18.0},
inputs={Items.BrassIngot: 25.0},
)
SteelBolt = Recipe(
name="Steel Bolt",
building=Machines.Constructor,
outputs={Items.SteelBolt: 37.5},
inputs={Items.SteelRod: 12.5},
)
HighPressureDiamond = Recipe(
name="High Pressure Diamond",
building=Machines.Constructor,
outputs={Items.Diamonds: 1.0},
inputs={Items.CarbonPowder: 20.0},
)
# Foundry
# - Building Parts
SolarCell = Recipe(
@@ -442,6 +515,25 @@ class Recipes(Enum):
Items.TinIngot: 15.0,
},
)
# - Industrial Parts
SteelBeam = Recipe(
name="Steel Beam",
building=Machines.Foundry,
outputs={Items.SteelBeam: 22.5},
inputs={
Items.SteelIngot: 60.0,
Items.ZincIngot: 20.0
},
)
CastSteelPipe = Recipe(
name="Cast Steel Pipe",
building=Machines.Foundry,
outputs={Items.SteelPipe: 45.0},
inputs={
Items.SteelIngot: 30.0,
Items.Sand: 24.0,
},
)
# - Other
ThermalSilica = Recipe(
name="Thermal Silica",
@@ -452,6 +544,15 @@ class Recipes(Enum):
Items.MagnesiumGranules: 27.0,
},
)
SaltySlag = Recipe(
name="Salty Slag",
building=Machines.Foundry,
outputs={Items.ColdSlag: 15.0},
inputs={
Items.Salt: 22.5,
Items.MagnesiumGranules: 30.0,
},
)
# Assembler
# - Building Parts
SmoothBeltDrive = Recipe(
@@ -583,6 +684,15 @@ class Recipes(Enum):
Items.CopperBusbars: 10.0,
},
)
Stator = Recipe(
name="Stator",
building=Machines.Assembler,
outputs={Items.Stator: 6.0},
inputs={
Items.SteelPipe: 18.0,
Items.TinnedWire: 36.0,
},
)
# Flexible Blast Furnace
# - Molten Metals
MoltenIron = Recipe(
@@ -619,7 +729,36 @@ class Recipes(Enum):
Items.MoltenCopper: 20.0,
},
)
MoltenSteel = Recipe(
name="Molten Steel",
building=Machines.FlexibleBlastFurnace,
outputs={
Items.MoltenSteel: 40.0,
Items.FlueGas: 30.0
},
inputs={
Items.MoltenIron: 40.0,
Items.CarbonPowder: 40.0,
Items.Steam: 60.0
},
)
# Reformer
# - Cooling
CastSteelRod = Recipe(
name="Cast Steel Rod",
building=Machines.Reformer,
outputs={
Items.SteelRod: 37.5,
},
inputs={
Items.MoltenSteel: 20.0,
Items.Water: 40.0,
},
byproducts={
Items.Steam: 40.0,
Items.ColdSlag: 15.0,
}
)
# - Ingots
CastIronIngot = Recipe(
name="Cast Iron Ingot",
@@ -669,6 +808,20 @@ class Recipes(Enum):
Items.Water: 15.0,
}
)
CastSteelIngot = Recipe(
name="Cast Steel Ingot",
building=Machines.Reformer,
outputs={
Items.SteelIngot: 90.0,
Items.FlueGas: 30.0,
Items.ColdSlag: 37.5,
},
inputs={
Items.CrushedGangue: 37.5,
Items.MoltenSteel: 30.0,
Items.Air: 30.0
}
)
# Wet Washer
# - Washing
WashedIron = Recipe(
@@ -707,5 +860,15 @@ class Recipes(Enum):
Items.Water: 30.0,
}
)
SteamMk1 = Recipe(
name="Steam Mk1",
building=Machines.BoilerMk1,
outputs={
Items.Steam: 30.0,
},
inputs={
Items.Water: 15.0,
}
)
Recipe.model_rebuild()

View File

@@ -147,11 +147,10 @@
<thead>
<tr>
<th class="done-col">Done</th>
<th>Output Item</th>
<th>Recipe</th>
<th>Building</th>
<th>Inputs</th>
<th>Destinations</th>
<th>Output Items</th>
<th>Building</th>
<th class="mono">Target rate</th>
<th class="mono">Per-building output</th>
<th class="mono">Buildings</th>
@@ -162,10 +161,8 @@
{% for s in result.steps %}
<tr>
<td class="done-col"><input type="checkbox" onchange="toggleDone(this)"></td>
<td>{{ s.item }}</td>
<td>{{ s.recipe }}</td>
<td>{{ s.building }}</td>
<td>
<td>
{% if s.inputs and s.inputs|length > 0 %}
<div>
{% for inp in s.inputs %}
@@ -176,7 +173,7 @@
<span class="pill">None</span>
{% endif %}
</td>
<td>
<td>
{% if s.destinations and s.destinations|length > 0 %}
<div>
{% for d in s.destinations %}
@@ -187,6 +184,9 @@
<span class="pill">None</span>
{% endif %}
</td>
<td>{{ s.building }}</td>
<td class="mono">{{ '%.2f'|format(s.target_rate) }}</td>
<td class="mono">{{ '%.2f'|format(s.per_building_output) }}</td>
<td class="mono">{{ '%.2f'|format(s.buildings_float) }} (~ {{ s.buildings }})</td>