View Single Post
Old 11-16-2012, 04:33 AM   #6
Viriato
New Member
 
Join Date: Jul 2007
Location: Lisbon, Portugal
Home MUD: Iberia MUD
Posts: 22
Viriato is on a distinguished road
Re: Event-based with threads instead of game loop

Good evening.
Iberia MUD is Java and multithreaded. One thread per client, one thread per core system. It is possible and not that consuming in a fair homemade server (just tested with few players). It is very interesting the fact that if something breaks, just that thread will be stuck and the rest will work as supposed (for instance, when combat breaks noone can fight, but the rest is up and works as supposed - army combat, all sorts of communicationm, etc). I get some troubles setting concurrency at times, but that's because development is slow and I forget some details :P

There is an important drawback: with one thread per client, if for instance two players "do 20 north", they wont arrive at same time (that's never like that, but the point is that there is no pooling of actions). Or I force a general pooling (which makes half the purpose of threads pointless), or in this special case I've put a delay in movement for everyone (still differs, but much less, and it's fairer).

Ah, items and objects don't have individually allocated threads. To give them "life", though, I made one thread for all moving NPC (it just deals with a big list and "distribute" orders to NPC when the time arrives) and one thread for temporary phrases. So, main architecture like that (weather has it's own thread, season of year the same, etc, etc).
Viriato is offline   Reply With Quote