🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Turn-based unlimited user game

Started by
1 comment, last by fleejay 23 years, 2 months ago
Hi, I''m trying to code a turn based unlimited user game (well virtually unlimited) at the moment I have the server listening for connections and handling them all very nicely using the select() command. I have a problem in that I always want the players to take their turn in a specific order. Is this just a matter of not listening to the clients until it is their go? If it is, how would I go about doing this with the select() command?? Thanx in advance. --- Fleejay
---Fleejay
Advertisement
There is a simple solution to your problem. Mandate that before a user can send his packet information he must recieve a go-ahead from the server. All the go ahead are sent out at once to all of the clients, but you never know in which order the replies will come back. Basically the "go-ahead" is the server telling the client that it can generate one turn of information. Now on the server side queue up all of the incoming packets(denote which player sent the data inside of the packet.) Then, after a time-out time, or when all the packets have been receieved (keep count) use an ordered remove from the array. This way you can process them in the order you want.

I must warn you; if you plan on making it massively multiplayer capable, you may not want to mandate player order. Also you''ll have to be concerned with packet loss and player drop. In a large player game, requiring a confirmation and go-ahead requires a lot of extra traffic. In the case of a turn based game it''s not so bad, but in the case of a real-time game it is a big issue.

Hope I helped.

RandomTask
Thanks for the ideas RandomTask.

The ''game'' isn''t really a game as such, it is more supposed to be an open AI test-bed. I didn''t want any limits on the number of clients, so at the moment it will support any number.

Because it is a system with no constraints, it should be able to cope with real-time (for less clients) and turn-based (or semi-realtime) setups.

Also because it is open, it should allow clients to connect at any time, with new clients taking their turn at the end.

Basically I''m trying to make something powerful enough to play, say soccer, where every player on the pitch is controlled by a separate AI client. Another client could connect and he could be substituted onto the pitch... (you get the idea)

In this game of soccer I would at least want to ask every client on the pitch if they wanted to move each ''turn'', whether they were going to or not. After I had asked each one of them for their action, I could then update all the clients with the entire game state (ie everyone''s position)

I suppose the real problem is ensuring that every client has told the server what it wants to do. Is it possible to check that using select()?

BTW as a side effect the server will display the game state from a neutral administration position, which complicates matters a little as I need a redraw in there somewhere.

Thanx again.


---

Fleejay
---Fleejay

This topic is closed to new replies.

Advertisement