Does anyone here have experience making games with streaming economies? I am working on a game and am looking for a better way to handle the economy. I feel like there must be a better algorithm than what I am using.
Background:
ResourceBin
objects contain resourcesSettlement
objects containResourceBin
objectsSettlement
objects have three queues ofBuilding
objects in arrays (Low, Medium, and High priorities)Building
objects have anextTick()
method that accepts aResourceBin
and modifies it
Right now on every tick the Settlement
class will loop through all of the Building
arrays starting with High and working towards Low. On each Building
object it calls the nextTick()
method and passes its ResourceBin
. After making sure that the transforms won't cause any Resource to become negative, the nextTick()
method modifies the ResourceBin
and exits. If any of its transformations would cause a Resource to become negative it just exits.
The issue with this is that the entire system depends heavily on the order in which the buildings are processed. I also can't have it proportionally affect the resource transformations if you are low on resources (like what is done in Total Annihilation).
Does anyone know how other games implement streaming economies? Is there a better way to do this?
Also let me know in the comments if a code example would be useful. I can pastebin one if need be.