Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

What I am attempting to make is a faux real-time game engine in node.js (taking advantage of the non-blocking I/O). When I say 'faux real-time' what I mean is I want players to interact with the world as much as possible without players blocking each other or having to 'wait in line to use the world'.

That is, unless the gameplay requires it. For example, in real life you have to wait in line to do certain things, some as simple as taking up space on a certain section of the highway. However if each person is in their own space, they can do jumping jacks or spin donuts in their car at a unique pace completely unrelated and 'in parallel' to every other person who is also taking these unrelated actions.

Related/synchronized actions would be things like trading, or even moving. If two players move into the same space and attempt to pick up the same object then suddenly it matters if they get there at the same time...

I hope this is making sense, but I'll add some code to try and give an example:

setInterval(function() {
     for(var i = 0; i < someArray.length; i++){
         someArray[i].QueuedAction();     
     }
     someArray = new Array();
}, 1000);

If every 1 second we went through this array and then emptied it, we would effectively have a synchronized list. There may be many events coming in to add to this array while this loop is running, but this loop is blocking those events from modifying the array until it is done and has cleared the array. This would be list of things happening in order.

However if this takes too long, then it will also block players from requesting their current location or the client from requesting objects around the player, etc. So this needs to happen quickly to keep the illusion of real-time but in order to keep the illusion of a logical world.

Is there any patterns I should evaluate that could improve this balance of in-order yet non-blocking world game engine?

share|improve this question
    
PHD student? The title of your question looks like the title of a thesis. :) –  Byte56 Jan 25 '13 at 18:20
    
@Byte56 nope, just a side hobby –  ioSamurai Jan 25 '13 at 18:21
    
Might be helpful to learn about the Node.js event loop and maybe multiplayer networking. What problems do you foresee with implementing that? It sounds like any other online multiplayer game. –  Anko Dec 11 at 2:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.