it's not needed, but know OGame and alikes helps to understand.
Way back in my "early" days (around 10 - 15 years ago) I played a lot of browser games like OGame, HackTheNet, WorldHackOrg and such ... and always wondered: How do these work on the server side backend.
One of those, can't remember wich, maybe even ogame, once released an old version wich was just a few php files and a few notes on how to set it up and that it's important a few files get's called in certain time frames to keep the game up. All it ended up with, as far as I understood it back then, where a few formulars with timestamps based on data stored in the database re-newed each time a player did a action, or for those not active online, done in those time intervals.
A few years later I was able to implement a very rudimentary "engine" (one would call it now days "early alpha"). It had a few buildings and a few resources, just barely enough to have a basic eco like: energy production, resource collection, storage (if you know OGame pretty much basic mines, storage and power plant). It was far from having things like research and even further away from player interaction.
It basicly worked like this way:
- the base clock was set to 10min - so, if some action started, like upgrade a knew building, and this action took more than 10min, the server send to the client: don't pull me in the next 10min - there will be no updates - or, if some action would fin in the next 10min the server would reply: pull again in X amount time - I'll have new updates for you
- as it was implemented in java there ran threads on the client active wait for an action to complete - so, when an action was started, the server replied how long it'll take and the client kept active track no matter of the over all 10min cycle
- the resources where interpolated - means, instead of only display the value calculated on last server action, but active counting - this was done by server send rates for how much of a resource was gathered in wich time (could be negative!) - an addition I would may consider today: based on what the players would like, I would either implement it the way like age of empires: when you want to build something to resources gets taken away all at once and you need at least the amount of resources to order - or like red alert: doesn't matter if you have the resources now, and they wont get taken all by once but over time as the build progress - maybe even mixing both - I would the players decide what they like more
So, as I had these very basics done, one could start to farm resources and upgrade buildings and manage eco and energy.
Adding buildings, units, research - I guess that's not that hard to implement a basic "tech tree" and come up with formulars that can factor in additional benefits like faster process or combine of stuff to make new stuff available (like settlers: you need coal and iron ore to make iron to make tools and weapon).
But what about scaling? Wiki says ogame has 2 mil players - is it really that easy to crunch that many datasets with possible collision of active players getting calculated each action they do instead of regular time interval for offline ones? Also, what about calc errors - the more datasets you have the more time it needs to update all calculations. When you start at the first and get to 10'000s you may already a few seconds in. For a high rank player this lack of precision could mean 1000s of resources missing behind what the actual should have. I can see how this would work for a small community - but for massive servers with thousands of players each may request huge datasets at same time (would end up in timeouts for some of the higher latency connections)?
never mind - I guess that's something to re-plan when you get big.
Another thing I never got my head around: How does player interaction work on such games?
To stick to the example of OGame: I sent a command: attack player X with fleet - wich takes time for the way to flight to player X - then a bit of "action" - and the return. How such events calculated? Active? Or by wich ever thread comes first of one of the players, or if both inactive for more than 10min, just the usual server side cycle? I guess that's a topic I need much help with - it's hard to find such specific information on the net.
There are lots of ways to do stuff like this and the optimal ways will depend on what needs to be done, for whom, and who needs to know what was done. That's also true of complex web applications like airline reservation and scheduling systems. The difference between a business server and a game server is more how seriously you take its functionality than anything else. And, of course some people take their games very seriously.
Let's take something like a 3-D space battle game server. I'd expect there to be a Universe object and a master Universe thread running continuously, although other options are possible. Things like planets and hazards would be objects defined withing the collection named Universe. They might have threads or fibers of their own (a planet might move in an orbital trajectory).
Now lets add external influences. That is to say, players. A player would operate as a client, and the player's actions would then trigger events in the Universe. Plus the Universe would likely contain Player objects so that players could see and interact with each other.
Events of interest to the player would be sent back to the player, either via general broadcast or customized event messages determined by the attributes of the player. Example, you wouldn't want to send a custom message about something going on outside of the player's sensor range. The mechanisms for data going to/from the player can be any of a number of different channels, from simple HTTP requests to the server to full real-time duplex communications channels, depending on how much overhead you can stand - and how much work you want to do.
Really no one size fits all.
Sources may include data from the Fakebook Research Foundation with support from Gargle University
Well, I'm aware that for obvious reasons there can't be such thing as "one size fits it all" - what "bothers" me, that there're not much information to find, or I'm not really able to find them. I also tried to look up some books (even in languages I don't know) - but no luck there either. Sure, I tried to "simplify" my search, not just looking for my specific topic but overall multi-user networked applications and games in general. Unfortunately I was only able to find information about specific frameworks or technologies not matter to me (try to mix up these words in google: browser, engine, game, java - you'll be surprised what comes up).
So, I'm not specific looking for something "ok, teach me how I implement something like ogame in java", well in the end I do, but to get there I need to learn about game development, multi-user interaction, split between backend business logic and frontend presentation - and somehow form that all together to get into the direction I might want. I don't know if I'm just not able to find resoruces for such topics, or if my selection of "what's relevant to me" not what it would be helpful to.
So, if someone know resources for maybe small topics that help to reach the overall goal I'll be thankful, also even books (if possible, please keep it to german or english - or some translated versions), although I currently don't have much money to spare.
Well, pretty much the universal rule to solving a problem is break it up into simpler problems. For a game, I'd start out with simply defining a playing field - typically a co-ordinate space like an 8x8 chessboard or 3-dimensional intergalactic field.
Along with that, I'd define a player: how the player moves, how it acts. Integrate that into the playing field.
Now at this point we're talking single-user, local machine operation only. You don't actually need a server (after all, Pac-Man did fine without one). Flesh this framework out as desired.
The server comes in when you want to have a common meeting point for physically separated players. Again, Pong, while having multiple players, didn't require a server or networking.
The server holds information about how the players relate to each other. Mostly you want the heavy computation to offload onto the clients so that the workload will be distributed and thus the server can accommodate more players. The server is what keeps everyone informed about everyone else.
So there's no real magic here, simply a pragmatic approach to problem solving. And, repeating myself, the first step is to adequately define the problem itself.
Sources may include data from the Fakebook Research Foundation with support from Gargle University
Ok, although in this very case I rather wouldn't offload any computation to the clients but all is handled server side - as in my specific "problem" the clients are more like only input forwarders and result displays instead of anything compute themself (pretty much a browser does - accept user input wich then sends a request to the server and displays the response).
nvm - to define and break down - maybe this is where I need help in the first place =D:
If I would asked to try to simply define my goal as an abstract problem to solve, I would try to start like this:
- repeated calculation of given formular based on last value and passed time since last calculation
So, based on this simplified version, I can see that my main loop just would consist of repeated call of the calculation function - wich just takes two inputs: last value and time difference.
A possible start might be, instead of think about the formulars or how to communcate with the clients I should first start to think about how to perform the calculation in the first place.
Oh, sure, you could do that. Or you could eat some pie. While reading this tiny ad: