I got a little client side auto battle game going, you pick some units and the battle progresses visually but automatically with a lot of random elements. However, I want need to verify the outcome by the server. I also want to be able to let clients duel other clients. So what is the best take on this problem?
-
Instead of heaving the complete battle play out on the server or check/compare every action from the client that is being played out randomly I figured it must be possible to just calculate the outcome quickly and once the client has finished the battle just verify that result with the server. I would just generate a seed on the server, pass that to the clients so the battle can be generated and played for them. In the meantime the server quickly calculates the outcome and checks that result with the client. Is this possible at all?
- Would a seed generate the same random numbers on each and every machine when using the same Random() implementation?
- Should I just loop trough the whole battle on the server side? Like moving each unit, detect hit, fight, damage, etc but instead of doing that each frame just in a single loop? Can I perhaps skip trough and interpolate these steps?
-
Just let the game play on the client and check each action with the server. Both clients would still need to get the same seed and the server needs the match the action with it's own "battle".
- I expect the outcome of both clients to defer from the server outcome. Same as above.
-
Have the server run and dictate the battle and the client just displays what is happening.
- Since the battle has random elements the client needs to ask the server each frame what to do which is a problem.
- I really cannot set the random aspect aside, units have to be able to "dodge" or "critical" every now and then. But perhaps this can be implemented in a different way since the battle outcome should be fixed.
As you see I'm having trouble wrapping my head around the whole concept. I have a fairly good understanding of network gaming. when the player controls a character you could let the client just do it's thing and occasionally checking variables and correcting the client based on server state. With my automatic battle the outcome of the game should be fixed and predetermined, especially when having clients PvP.