I have a problem. I am making a game played on a grid (not necessarily the size above). The orange dot denotes a "resource" producer. The numbers represent the amount of resource in each cell. The arrows are the ways that resources move from cell to cell and is selectable by the player to move the resources around the map. Resources in each cell are capped at 100.
The problem is that on each update each cell is checked to see if it has an "arrow" moving out of it to a neighbor cell and if so it will transfer some resources. It will only do so if it its own resources are at least 2 (since we must retain at least 1 in each cell) and if the neighbor cell is not already maxed out. Cells are updated in order from bottom left to top right. In the example in the picture I get a deadlock like situation where no additional resources make it into the system from the producer. Since the updates take place from bottom left to top right the first one to get an update is the bottom left. It checks it has more than one, has an arrow going up, the one going to it is not maxed so it transfers one resource reducing itself to 1 and the one above it to 100. Next update is the bottom right "2" and it does same thing. The issue that happens is that when it gets to the producer cell the producer cannot transfer a resource right into the connected cell because it was updated to 100 by the cell below it. And then the next one updated is that new "100" which transfers resources to the cell to its right and falls back down to 99.
So what happens is that there in that tight loop those 4 keep passing around 1 resource to each other in a loop and doesnt allow the producer to inject more because its neighbor is at the max (100) when it is the producers turn.
yes i have considered updating from top down but it will still be the same problem just with a different corner or orientation of the loop.
I have also consider updating all producer cells first then go through the rest but the problem still remains if there is an additional cell between the producer and the loop. Just image the loop moved one space to the right with an extra normal cell now linking the producer to the loop.
I do not want to limit the ability to make loops. I have considered each arrow to be bi-directional and only allow resource movement to lower resource level cell but this causes all cells to update at same value and doesnt allow "surging" of resources to given areas.
How to overcome this prevention of introducing new resources by the producer?