A recursive recipe calculator inspired by chemistry
Aequus helps you calculate the total quantities of raw materials for recipes. The recipes can be simple or have dozens of ingredients. For ingredients that are themselves creatable, it can recurse through them until you arrive at a complete calculation of every raw material needed to create something.
"Aequus" is a Latin word that can mean "equal" or "like." This application draws inspiration from chemical equations because balancing chemical equations and complex recipes share many concepts.
You can use this program for cooking recipes in real life, crafting recipes in simulations or video games (like Minecraft), or anywhere recipes appear. It is designed in an abstract way to allow the definition of recipes of many kinds.
Calculate the total raw materials needed to create 16 sticks in Minecraft:
python -m calc product_name target_quantity [source_mod]
python -m calc stick 16
The source mod is only required if multiple items exist in the ItemDatabase
sharing the same name.
Product: Stick
Target quantity: 16
Bill of raw materials:
2 Log
Explanation:
2 Log = 8 Oak Planks = 16 Sticks
python -m pytest
- Recursive calculation of raw materials
- Support for probabilistic ingredients (things created through a chance-based process)
- Define jobs to produce n quantity of an item and calculate the raw materials needed for the job
- Define multiple recipes per product
Entity | Definition | Example |
---|---|---|
Item |
Something that exists in a stable form, whether it can be made or gathered | Stick |
RecipeComponent |
A combination of an Item and a quantity |
2 Oak Planks |
Reactant |
A RecipeComponent that is used to create one or more Products |
2 Oak Planks |
Product |
A RecipeComponent that is created from one or more Reactants in a recipe |
4 Sticks |
Recipe |
A group of Reactants and Products |
2 Oak Planks = 4 Sticks |
BillOfMaterials |
A collection of Reactants that have been recursively reduced to their raw materials |
2 Log |
Job |
A combination of a Recipe , the desired Product , a target quantity, and a BillOfMaterials (BOM) |
Recipe: (2 Oak Planks = 4 Sticks), Product: Sticks, Target quantity: 16, BOM: 2 Log |
ItemDatabase |
A collection of known Items |
Stick, Button, Oak Planks |
RecipeDatabase |
A collection of Recipes associated with Products |
Product: Stick, Recipe: 2 Oak Planks = 4 Sticks |
The following equations are a mathematical expression of crafting 16 sticks. It models the full series of subcomponents, tracing back to the Log raw material.
Step 1 - Express the chain of recipes to craft 16 sticks
Step 2 - Reduce fractions
Step 3 - Cancel like units
Step 4 - Apply the identity property of multiplication
Step 5 - Multiply fractions
Step 6 - Reduce fraction
Step 7 - Apply the identity property of division
Aequus automates these operations for any recipe to determine equivalence between a desired product and the raw materials needed to make the chain of subcomponents that make up that product.