Advertisement Jump to content
Sign in to follow this  
Brunno Tavares

How it works

This topic is 1834 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I’m wondering how games like Clash of Clans or Samurai Siege are developed.

I know that involve isometric maps etc…but I can’t imagine how the server side are developed.

Everything that I think, it seems slow. For example, in this kind of game, we can build some kind of Resource Producer, and this build take some time to be complete.

How this logic works I mean.
There is one record for every player in some kind of DB ?
This TIME is controled by CRON in server or the Game Loop check every object for every player?

I tried to find some kind of tutorial but i just know this kind of game as “Time Management Game” and I couldn’t find nothing ?


Sorry my bad english

Share this post

Link to post
Share on other sites

This question has been discussed before on the forums.


The main consensus is that you don't need to resolve things "as they happen;" you only need to resolve things "as they are observed."


The actual simulation is dead simple -- any computer these days can fast-forward a month worth of "simulation" in less than a second. Especially given that most of these games have a "stop point" where they won't produce "more" until they are "harvested," which puts an upper bound on the amount of simulation needed.


So, the server just needs to store the current state and the time of that state for the player. Then, when the player says "build a X at time Y" or someone says "show me the state at time Y," the server will load the stored state, fast-forward the simulation to the time Y, and then store that state back as well as return it to the player.


And, yes, the state for each player is stored in some database -- it could be as simple as a file-on-disk for each player, or as advanced as a graph database serialized to a relational schema, or something in-between. Most likely a document store like MongoDB or Riak or whatever, or a TEXT column in MySQL.

Share this post

Link to post
Share on other sites
These type of games usually just keep a real-world timestamp representing the finish time.  The timestamp works regardless of framerate, suspending the app, killing the app, etc.

Nothing happens when the game is not running, but when it starts back up and loads the game, it begins examining the timestamps again and finds out that the current time > the timestamp, so the timer is complete. Or, if the current time STILL isn't > timestamp, then just display the time remaining. Edited by Nypyren

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!