If possible create a ,boolean full, propose is that when the thing is full or clogged or over it will turn true which causes power consumption disabled but redundant power continue (Simply it will act as relay)(Silly approach I know)
Considering a connected graph, I think that the biggest problem is to choose the generator(s) to shut down, like what would be the criterion for that? In general if we consider only their output power then it looks like a _change-making problem_. But considering that some generators consume more resources per unit power it gets complicated (let alone considering different value of resources :)).
Anyway a greedy approach would probably be good enough for that but I think it still needs an order on generators set (even a simple one like the power output).
edit:
Or we could just slow down power production in every producer node proportionally. For example if we need 90 units of power and produces generates 100, we could slow down _every_ producer by 10% and as a result the resources would be also consumed 10% slower in _every_ producer.
It will require changing how power works, from the source giving power to the users, to the users requesting power from the source.
Maybe.. but I think it doesn't matter. The current approach (having a power pool being created at every update and then distributed) seems just fine.
Anyway, it won't significantly help to solve any of the challenges I've mentioned in the previous comment.
New Approach, (working on factories rather than powers system)
Make factories to detach to node on clog or full and automatically connect when something happens. Your own choice how to set this stimulation.
! We might lose redundancy.
@Anuken
I'm new to this game, what do you mean by 'no power is being requested'?
Only things I can think are if their is no attached batteries, or the batteries attached are full
I'm referring to situations where you have a generator running on its own with no outputs, or a group of generators producing 100 power/sec while the grid only consumes 50 power/sec.
@Anuken
Working on this now. Looking at code it looks like power is given fully to every consumer. Is that correct?
For example if a tile is producing '50 power' and there are 2 units that need '50 power', will each one get 50? Or will they both get 25?
Each will receive 25.
@Anuken PR #825 should do the trick. Let me know if theirs any issues or suggestions relating to it
might be "naive" but why not act like the factories ? make a small reserve of power inside every generator (even a hidden one) then if power is not consumed (ie : the power grid is already in a positive state) the reserve will fill, at full capacity, stop production, as soon as reserve decrease, restart production ?
@runiArnsbjornson Yep, this is what I am working on now. A hidden 'overflow', used when power is short, or when it can count for an entire input
Not sure how to move this back to draft, will be a while before I continue it
@LionelBergen , just close the pr but dont delete the branch. You can make a new PR whenever you want.
@Anuken don't power relays and nodes consume power themselves? If they do, then we'd have to think of a concept like 'is a customer connected to a node' and inherit that back up to the generator.
Another fun wrinkel, what to do about Thorium reactors, which can explode if you're not careful in disconnecting their resources.
don't power relays and nodes consume power themselves?
Nope.
I was thinking about this recently, and I believe a simple solution involves the following:
This would make the power output continue to be the same (visually), but resources would only be consumed proportionally to how much power is actually used. For example, if only 50% of power is used from a combustion generator, then coal would be consumed at half rate.
Make building pause
if not possible to cut power at being full.
Make it work like in Factorio. Every generator has a performance variable that changes according to demand. Prioritize renewable energy (solar panels) over other energy. Every power grid has "avaiable performance" - sum of all maximum power outputs of every battery, "power consumption" - sum of all power consumptions of each consumer and "satisfaction" - how much power you consume vs max performance.
Batteries will act as power consumers with excess power and as generators when theres a lack of power.
Edit: Sorry for weird formatting, I'm on mobile.
Hmm, just had a thought, won't this trick users into a false positive?
"oh wow, this 1 grey belt of coal can feed 40 steam engines!"
Or in other words, making users believe their fuel supply setup is perfect, only for it to run dry when more power is consumed 馃槜
One thing that would be interesting and would encourage building and design from the players is an indicator and logic gate/switch gate. An indicator could determines when power is positive or negative. It could be an LED so the player could also use it to monitor the power graph, perhaps green when <+1000W/s, yellow when +100-+1000W/s, flashing yellow when >+100, slowly flashing red when >0 and consuming reserve power, and rapidly flashing red when no reserve power and production is less than 0. This could be placed next to a toggleable gate of some kind ("Power Gate" or something) that would open when the indicator is a certain color/state or when a player taps/clicks on it. I could choose to only produce more power when I'm low and produce graphite or silicon when I have reserves back. That would be two whole new blocks but they would be useful in other situations as well.
I have raised a PR for this here - https://github.com/Anuken/Mindustry/pull/1137
Most helpful comment
Hmm, just had a thought, won't this trick users into a false positive?
Or in other words, making users believe their fuel supply setup is perfect, only for it to run dry when more power is consumed 馃槜