It already is deterministic…
But even with that I’m having trouble comprehending how to make this networked, I have sort of the general jist of it on the tip of my brain, but can’t quite wrap my head around it. So if you’ll excuse as I think out loud for a moment, and I’d appreciate it if anyone could correct or guide my thinking.
See each players input changes the liquid, the players essentially slosh around this goo. So the simulations input variable could be changing up to 30 times a second.
I am thinking to do this determinstically, what would have to happen is each players inputs would have to be synced. So each player inputs their input, sends it to the server, the server distributes all the input to each player, each player would wait to receive the updated inputs, and upon recieval, each player would update one cycle of simulation, all producing the same outcome. correct?
However this is where things get tricky for me and I can’t wrap my head around it. The simulation is running on a second thread. The simulation may actually update anywhere between 10 and 30 fps, but the actual game Update loop is on the main thread and is going 60 fps, interpolating the movements of liquid between each full accurate update of the simulation.
So I am thinking, the simulation thread would have to be put on pause, wait to recieve the next iteration of inputs from the server, while interpolating from the last simulation, then upon recieval of the inputs, unpause the simulation thread, let it run for one cycle, then repause it, wait for next iteration of inputs. But that seems like there would be such a delay… and how would I prevent it from over-interpolating further than it should? Like some of the liquid may be interpolated farther than another players liquid, and by the time the next cycle of the simulation thread occurs the liquid could all be out of sync from the interpolation. I would still have to verify each cell of the simulation grid against each client…
Unless I do something like keep track of the average time between network updates, and have it interpolate only up to that averaged amount of time, so then the interpolation would be controlled, and the same on all devices…
I’m confusing the hell out of myself here…
Am I thinking about this right?
After some more thought I am thinking potentially the best way to do this is to just have each player fully simulate the liquid at full speed individually, based on the stream of inputs from other players. Then as data and latency permits, it will gradually go through and verify the synchronization of the simulation. So it won’t sent all 40,000 cells every update. It may send only 2,000 cells an update, and then the next update send the next 2,000 cells, then next update, the next 2,000 cells. And if there is an out of sync cell disocvered, it will correct it. So the simulation may be ‘slightly’ off, but the mis-sync wouldn’t last more than a second typically.