Network turn-based game question

Started by
3 comments, last by goodeddie 11 years ago

When should I broadcast my own action?

Do I broadcast on state change? Like if I start moving, I broadcast it. But do I also have to broadcast when I stop moving?

Or do I just broadcast on a valid input like when I press a button and it's valid?

Advertisement

It depends on your game.

Usually, by 'turn-based', people mean a game with discrete player positions. For example, in Chess, a piece can only be in one of 64 different places. So there's no need to send updates during movement, because movement can be represented instantly (eg. Bishop from B1-E4). The receiving side can decide to animate that if it wants - but that's a presentation decision, not something intrinsic to the rules of the game, and there's not usually a reason why the sender would need to explicitly show the game object moving through those intermediate positions. So typically there would be one message sent, describing the change in terms of the game rules. You wouldn't send hardware-specific input (eg. button presses), nor would you need to send start/stop actions, because you can usually describe it adequately in one message.

Even if you do have a continuous game world (as opposed to a discrete one), there's still no need to be sending updates in real-time. It's a turn-based game and all that matters is that the other player gets to see what happened during the turn and gets an accurate representation of the game state at the start of their next turn. So when you send the updates is up to you, as long as the recipient gets all the information they need to recreate the events of the past turn, and the game state at the start of this turn.

Most games are essentially real-time, which has different requirements. You need regular updates of the other player positions in order for them to be valid at all times. In this case, the simplest situation is just to broadcast the player's current state, all of the time, so that the other computers can just update their local values based on the new information. It also helps to broadcast start and stop messages so that any guesses about what a player are doing (eg. extrapolation based on past velocity) can be corrected if necessary.

Thanks!

My server is slow and low on memory so I'm trying to limit the number of messages sent to one or two. Then I let the client side handle drawing the movement inbetween the start and the end. But thanks!

Another question I have is: In a network game, does the client send it's state change to the server and the server adds it to a queue and the server loops through that queue and broadcasts it?

Thanks!

My server is slow and low on memory so I'm trying to limit the number of messages sent to one or two. Then I let the client side handle drawing the movement inbetween the start and the end. But thanks!

Another question I have is: In a network game, does the client send it's state change to the server and the server adds it to a queue and the server loops through that queue and broadcasts it?

That is one way to deal with it, but mostly you should receive a message from a player, say:

move from [1][5] to [2][7].

The server receives and process the information. In this case you can just process broadcast the message.

But if you have a game like a Final Fantasy Tactics and the char that just moved lays a trap on [3][6]. In this case, the server shall process the information, but must not broadcast the trap postion (since the enemy player should not know where the trap is, otherwise he will not step on it).

In other words, you can simply broadcast messages, but you should be careful on what you are broadcasting, some information must not be sent to other clients.

Currently working on a scene editor for ORX (http://orx-project.org), using kivy (http://kivy.org).

You can only broadcast moving from one pos to another pos after you're done moving lol but thanks! I think I'll just send to server at start of action.

This topic is closed to new replies.

Advertisement