Network communication for a turn based board game
Posted
by randooom
on Stack Overflow
See other posts from Stack Overflow
or by randooom
Published on 2010-06-03T00:52:12Z
Indexed on
2010/06/03
0:54 UTC
Read the original article
Hit count: 407
Hi all,
my first question here, so please don't be to harsh if something went wrong :)
I'm currently a CS student (from Germany, if this info is of any use ;) ) and we got a, free selectable, programming assignment, which we have to write in a C++/CLI Windows Forms Application.
My team, two others and me, decided to go for a network-compatible port of the board game Risk.
We divided the work in 3 Parts, namely UI, game logic and network. Now we're on the part where we have to get everything working together and the big question mark is, how to get the clients synchronized with each other?
Our approach so far is, that each client has all information necessary to calculate and/or execute all possible actions. Actually the clients have all information available at all, aside from the game-initializing phase (add players, select map, etc.), which needs one "super-client" with some extra stuff to control things.
This is the standard scenario of our approach:
- player performs action, the action is valid and got executed on the players client
- action is sent over the network
- action is executed on the other clients
The design (i.e. no or code so far) we came up with so far, is something like the following pseudo sequence diagram.
Gui, Controller and Network implement all possible actions (i.e. all actions which change data) as methods from an interface. So each part can implement the method in a way to get their job done.
Example with Action():
On the player side's Client:
Player-->Gui.Action()
Gui-->Controller.Action()
Controller-->Logic.Action
(Logic.Action() == NoError)?
Controller-->Network.Action()
Network-->Parser.ParseAction()
Network.Send(msg)
On all other clients:
Network.Recv(msg)
Network-->Parser.Deparse(msg)
Parser-->Logic.Action()
Logic-->Gui.Action()
The questions:
Is this a viable approach to our task?
Any better/easier way to this?
Recommendations, critique?
Our knowledge (so you can better target your answer):
We are on the beginner side, in regards to programming on a somewhat larger projects with a small team. All of us have some general programming experience and basic understanding of the .Net Libraries and Windows Forms.
If you need any further information, please feel free to ask.
© Stack Overflow or respective owner