views:

166

answers:

2

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:

  1. player performs action, the action is valid and got executed on the players client
  2. action is sent over the network
  3. 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.

A: 

All I know is that I wouldn't say C++ is a language for beginners! I've never used it, but friends of mine who have descibe it as "a man's language". I guess it puts hairs on your chest.

I've never written an app like this, and whilst some would say Winforms / thick clients are making a come-back I think the majority of peopel out there will be doing web-based development.

I guess WCF would be a logical place to look, but I haven't used it for peer-to-peer stuff before.

How do you know which other clients are out there, so you can play with them? Teleconferenceing solutions seem to use a centralised system: you dial into a specific number and it tells you you're the first person to join the conference. If someone leaves everyone else is still there. This might be more what you're after - let a central system mediate the data. What happens if two clients send conflicting actions?

With a central system you'd be able to build straight forward rules to govern the game, and it'd be easier to manage. You can wrap teh handling of actins in a transaction so that you don't get conflicts. the only issue then is keeping all the clients sync'd up; all they have to do is get an update from the central server - but when do they do that? do they just poll it or are they "told" by the central server when there's been a change? The latter is probably much better - but I don't know how you'd do it using the technology you're proposing.

I hope that helps.

Adrian K
Hi, thanks for your answer.The thing is, we have to use exactly these technology i.e. C++/CLI and .Net Windows Form. It is not even possible to use an other .Net language, our prof is very strict in this regard :) (do not ask me why.) What I wanted to say with the beginner thing is, that all of us know C++ and the .NET stuff, at least the theoretical side. But neither of us has any "real world" programming experience not to mention with a project of this scale.
randooom
And yes we use a server/client approach. The Network Class in my example above is just an abstraction for the whole network stuff. But the server is just there to manage connections and clients and to broadcast incoming actions to all other clients. With the above approach we see no need to give the server more power, because each client can do the calculating and stuff on its own.
randooom
Certainly sounds like you know what you're doing. I'm just sorry I don't have any real-world advice to give you - that seems applicable.
Adrian K
There is nothing to be sorry for :)
randooom
Actually I just want to check, if our approach is possible and does not only look good on paper. So we do not have to code for 3 weeks only to see that this was all bs. This is where I think real experience might help, to know the difference between what looks good in theory and what really is practically realizable.
randooom
A: 

Generally the idea looks okay. To prove the idea in pseudo code you can design small prototype.

Since, the game you want to build is turn based - you need guaranteed network delivery. For data transfer simplification you can use proto buff library

Vadmyst
thx, we really have to take a closer look into serialization, if only for game saving. Something new to learn :)
randooom