Power Overload


Performant, semi-realistic power distribution overhaul. Power poles can explode if the total electrical consumption on the network is too high. Use transformers to separate networks so that subnetworks do not take more power than they can handle.

Content
1 year, 2 months ago
1.1
3.07K
Power

g [Completed-1.2.0] Optimization thought

2 years ago

since every pole in the same network has the same power reading, would it make sense to have a
map<power network id, map<max consumption, poles[]>>
and check one pole per network and then apply the consumption behavior to the right poles eg. damage or explode them?

for network, con_poles_map of map
max con = get max con con_poles[0].poles[0]
// go through consumptions and test if consumption > max con

2 years ago

Thanks for the suggestion. I've not worked on this mod for a while (and won't be updating it for several months yet), but from what I can remember about the mod, this suggestion makes a lot of sense. Having it being based on networks could indeed be a lot more efficient. Keeping track of network IDs and which networks contain which poles could be tricky, but I think would be doable. Even without that, caching the calculated total consumptions for a given network ID each tick could be a big efficiency gain.

However, no-one's ever reported UPS issues with this mod, so it isn't high priority.

1 year, 11 months ago
(updated 1 year, 11 months ago)

So there's no way to get all electric networks without iterating through all poles, and there's no way to get any poles from a network. However, just implementing a naive cache which saves consumptions per electric_network_id each tick seems to be a 400% performance improvement, so I've gone with that in v1.2.0.

Thanks for the suggestion!

New response