system to consume resources over time
two features I'd like to add:
- loot-tokens kind of suck. Drop them. Instead, gain looted hatcheries over time:
- collect pre-hatcheries from combat, up to some cap based on the highest zone you've cleared
- pre-hatcheries convert into real hatcheries over time. the rate is based on the highest zone you've cleared (or other factors?)
- pre-hatcheries have a cap, so mashing attack all day gives very little (but not nothing!) at the cap
- autobuy. example: consume larvae and meat over time, output drones over time.
consuming resources over time this way isn't technically possible yet. Make it so.
implementing it involves:
- negative resource generation (easy)
- capped resources (easy)
- detecting where we cross zero (trickier, but doable in certain circumstances. solving for zero is easy for degree 2, okay for degree 3, possible but probably impractical beyond)
- after we hit zero, the curve changes, becoming based on the empty resource (tricky)
- if above are too tricky to generalize, figure out how to fudge the specific cases I care about (unknown)
The basic algorithm for continuous consumption here is:
- given: player's bank, production-per-resource, consumed-resources (cost), produced-resource
- identify which consumed-resource is growing the slowest at the start; that is, which resource is the bottleneck.
- produced-resource velocity = bottleneck-velocity / cost
- new-bottleneck velocity = 0 (that is, we're spending it all on produced-resource as it comes in)
- non-bottleneck-consumed-resources velocity -= produced-resource velocity * cost (velocity may drop below zero, but bank won't - see below)
- solve for the next zero (using linear/quadratic/cubic formula): when will another consumed-resource hit zero? when will the bottlenecked-resource change?
- no zeros for any consumed-resource: bottleneck will never change; we're done
- found a zero at time t: reify(t); goto start
One hiccup: slow-growing resources. Imagine having queens on autoclick while you only own one queen: drones should grow until you hit an even 100 drones, not stay at zero while you build half a queen. We'll need a discrete branch to the algorithm for smallish numbers.