Advertisement

How it works

Started by January 07, 2014 11:45 AM
2 comments, last by Nypyren 10 years, 10 months ago

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 ?

tks.
Brunno

Sorry my bad english

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.

enum Bool { True, False, FileNotFound };
Advertisement

Tks hplus0603,

In resume, Its just calculate the time it takes to finish a build when the player open the games. That's it ?

tks

Brunno

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.

This topic is closed to new replies.

Advertisement