Tuesday, August 18, 2015

The Heart of the Game

Deciding finally on the set of tools that I'm going to use was comforting but there was still a really big question, which I haven't addressed yet and which was really bothering me – how on the Earth all these games work? I mean, you start doing something in the game, you log off, then log in and it's all done. And presumably it's all happening in your browser without your involvement (updating later a database somewhere on the server). 

Well, I have to admit that if it is indeed somehow client-based, then I still don't know how it's done and what the secret is. Understanding that nobody is going to share this secret with me (but still unsuccessfully trying to Google it), I spent a lot of time wrecking my brain and trying to figure it out, but all to no avail… It was either extremely inefficient or just was not going to work at all. To let you understand better what it is all about, let's see an example: 

If you are sending your troops to attack somebody, it's going to take some time. When you launch this attack, a new task is created in the database and it's supposed to finish after some time. I don't want to wait all this time, so I log off, do something else, log in again tomorrow and can see that the battle happened when it was supposed to happen and your troops are already back home. The question is what made it to happen?  

The only way I could see it's happening purely on the client-side is to execute all pending tasks for a user at the moment when he (or she) logs in the game, back-dating all tasks with whatever date-time they were supposed to be executed and recursively iterating through tasks that depend on other tasks (e.g. returning your troops home). That would work in theory, but there would be so many complications, that in practice it would be totally inefficient.  

The only way I could see it happening is to have some external and independent mechanism that would be monitoring all existing tasks and when it's their time, pull them out of the database, execute them and update the database again. This mechanism will be controlling all processes happening in the game, and it will become ultimately the Heart of the Game. The decision was made again and I started working on the Undecima Task Manager. 

A downside of having an external application of that kind and why I actually tried so hard to figured out how to do it all on the client-side was the fact that now I'll have to hire a whole dedicated server to run this application and the cost of hosting this project would jump up hundred times comparing to a simple web-app that was initially in my mind.

No comments:

Post a Comment