Tuesday, March 4, 2014

Power System


Tiers of Power


Femtocraft is all about tiers and encapsulation.  Each tier, once researched, exposes another layer underneath it.  This theme propogates into the power system as well.  Each tier of decomposition has an accompanying tier of power - Micro, Nano, and Femto.

Each power storage is a wrapper around the previous tier.  The picture shown above is the Nano-Cube, which is the Nano-tier power storage device.  At the core of this multi-block is the Micro-Cube.  When the Femto-Cube is built, it is a wrapper around the Nano-Cube.  In this way, the latest tiers of Femtocraft still require infrastructure and items from the previous tiers.



The power system of Femtocraft is not coded using an energy net, nor does it require any pathfinding algorithm of any kind.  Each Femtocraft power block simply pushes power to neighboring blocks with less power.  In layman's terms, power flows from where it is generated to where it is needed.

In programming terms, each power block is a node in a greedy distribution system, where every tick a portion of the node's power is distributed among neighboring nodes with less power.

What this means is that there are no computational bottlenecks.  Power can't get lost in the system because there is no path-finding algorithm to confuse.  Power producers don't need to determine a path to every potential consumer, which could potentially require traversing hundreds of blocks.  Instead, they simply push their power out to the wire, which then pushes it out to the next wire, etc.  Each block only ever needs to perform a certain amount of computation every tick, and the amount of computation is capped to the number of neighbors it has.

This does mean that power does not propagate instantly when a new machine is connected to the system.  I feel that this fits the theme of Femtocraft better, and isn't much of a problem in usability.

Liquid Distribution


The liquid distribution system uses a near-identical algorithm.  This will be covered more in the following posts about utility transportation implementations.

No comments:

Post a Comment