So I was playing Clash of Clans, and just wondered on how they authenticate the result of the battle.

This isn't exactly specific to Clash of Clans though. In my observation, while CoC is an online game. Their battle is just a singleplayer, but still I feel like the battle is verified somewhere in their server?

This would apply to games that are :

  1. Singleplayer (no 2nd player to sync to).
  2. Doesn't need constant communication to server during battle.
  3. But the result still important and must be authenticated/verified.

My current guess is during/after a battle, the client app will send the inputs/actions of the player to the server. Then in server, the battle will be re-simulated again using the input/actions at a much faster time/pace.

For this to work, the battle has to be deterministic (unsure if that's the right word) so that same inputs/actions will produce the same result.

But if this is the "proper" way, then it would be really heavy on the server CPU's side isn't? even with scaling, I think.

I am leaning on this solution, but something doesn't feel right... there might be a better way...

That's why I came here today to consult for ideas/suggestions..

I'm thinking if there is a safe way to do the simulation/result on the client side? like encrypt the sensitive stuffs? is this even possible?

Thank you!

  • 2
    \$\begingroup\$ To be clear: you want to know what a good way to validate the results of a battle would be, not specifically how Clash of Clans does it, correct? (The latter is off-topic here.) \$\endgroup\$
    – user1430
    Feb 23, 2017 at 0:06
  • \$\begingroup\$ We can't answer how they did it for Clash of Clans. But this is an interesting question, so I suggest to slightly reword it to be more general. \$\endgroup\$
    – LukeG
    Feb 23, 2017 at 0:07

1 Answer 1


The general method would be to have the battles take place server side and simply have the clients relay the commands. Since CoC and similar types of games aren't like a competitive FPS that requires extremely low latency a little bit of delay to keep the clients synced would be no problem. Honestly, this is the only good way to do a real-time PvP game where the players aren't on a LAN.

The only other viable method (sort of) would be to use a deterministic battle system and a predetermined seed to simulate the battles. So when players join a battle the server would send a seed to each player so that they would each resolves actions the same way. The major flaw with that design is that each client would either have to wait for actions from the other player (slower than the server model) or they would run the risk of different outcomes based on the timing of commands.

edit: You could also use one of the clients as the "host" in place of the server, but you would still have to allow a delay for the commands from the opponent to be received with a time-stamp in order to resolve them properly (read: fairly) for both players.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .