Hopefully this will be clear enough.
I have a 2d map made of tiles, and I want "water" to travel through this map. It comes out of a pipe onto a specific tile, and then needs to fill up, like water, all the tiles to reach a certain other tile. I currently have the map inputted into the game with each tile being a node and each node having connections to all appropriate tiles around it. I have the nodes stored in a sorted array, first by x, then by y. Additionally, some tiles are 'gate' tiles, which can stop water from flowing through them. These are part of the same grid of node tiles and are just flagged when active.
The problem is how I disperse the water.
Initially I had each pipe (which drops water) keep track of a list of 'current' and 'full' water tiles, and it would disperse water directly to the 'current' tiles, and then switch them to its 'full' list when appropriate. The 'current' list was expanded by getting surrounding tiles of the already 'current' tiles. In any case, this worked well, and water flowed nicely, but I couldn't figure out how to make it work with the gates so that the flow of water could be stopped, and re-allowed, (and stopped again, etc.) at a specific point.
Right now I have it where the water dumps into one and only one tile, and then while a tile has too much water, it pushes the water incrementally onto a random neighboring tiles (unless the tile is an active gate.) The problem with this is that the water 'sloshes' around already filled tiles instead of flowing 'outward.' It will get there eventually, but the flow is much less natural.
Thus concludes my dilemma.
The code is written in python.
Edit: New idea. I could have the pipe search through the nodes for a suitable free tile to place the water every update, but this seems horribly inefficient--particularly with multiple pipes.