• Advertisement
Sign in to follow this  

Dedicated Server Process or Multithreaded AI?

This topic is 4370 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm working on a turn-based strategy game and am starting in on the networking code. I've come to a design choice i need some input on. The way most TBS games work, after all players have input their commands and press NEXT TURN, the computer then starts crunching the numbers to process the turn, then updates everyone afterwards. As far as the networking goes, in a client/server architecture, the server would be doing turn processing and then updating clients when it finishes. If however one of the players in the game is functioning as "the server", then his PC is going to lock up in a single-threaded environment as the turn is processed. That's not such a bad thing if they just have to stare at a static image, but it would be nice if they could be doing other things while they wait (like chat with other players). So now it comes down to two possible options to solve this problem: 1) Make the server it's own process. This way, the OS can do the "multi-threading" naturally. The server would have to make sure to destroy the process when finished though. Not too hard i'm sure (if players == 0 shutdown(); ) 2) Multi-thread the app. This way a player could act as a server and as a client both without the machine locking up as the server kicks into gear and starts processing the turn AND without spawning another process. This is obviously the more complex way to do it. I'm also not familiar with thread programming at all. BUT it would allow for the AI to run wild while real players are doing their turns. This way, there is less of a wait when the turn actually needs to be processed. What would you suggest i do?

Share this post


Link to post
Share on other sites
Advertisement
In my own current project, also a turn based strategy game, I multi-threaded it. Or rather, I wrote the server in such a way that it was self contained enough to run via thread, or to be run 'dedicated' by a seperate main that simply calls it.

I did not find much gain in multithreading it rather than not. Since you have to assume it might not be threaded, everything ends up going via networking anyways. That and you run into standard subtle threading issues [like statics being shared between server/client when they perhaps shouldn't].

There's been some gains in multithreading the server itself, but spawning the server as a thread of the client isn't particularly beneficial [in my limited experience].

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement