Author Topic: Multiplayer Solitaire  (Read 8427 times)


  • User
  • *
  • Posts: 3
Multiplayer Solitaire
« on: February 19, 2009, 08:01:10 AM »
I like to create a 2-4 player solitaire game. I never done network programming before so wondering if I can get help with ideas on the client/server infrastructure & network protocol. Then hopefully someone can start off some sample code to help me get started.

My current idea is that the server waits for client connections. All players in some chat lobby. The server has a "Start Game" button.

The server must shuffle each players' pack of cards and deal them out solitaire style. Each player has their own independent pack of cards so there's no duplicates.

The solitaire 4 ace base slots is multiplied by the number of players. So if there's 2 players, there are 4x2 ace base slots. If there's 4 players, there are 4x4 ace base slots. The ace base slots are public, shared among the players.

Aim of game is to solitaire throw away all your cards onto the ace base slots.

Upon game start, server allocates cards to all players. Am not sure whether to send out the entire card piles of just the top up-facing cards.

During game, clients will drag their top up-facing cards on top of each other according to solitaire rules (black - red - black, card on top must be 1 number less). I guess all this logic should be done on client-side. As soon as a player drags a valid card onto the ace base slot, the server gets notified, checks if valid move (incase another player got a card there first) and broadcasts to all other players. looks like a good starting point. The confusing bit is how to integrate with the network library and do the client/server logic above?


  • Administrator
  • User
  • *****
  • Posts: 147
Re: Multiplayer Solitaire
« Reply #1 on: February 20, 2009, 09:38:18 AM »
I don't know drac, but it could be a good starting point. What you have to do is evaluate whether or not it allows the application to have cards be locked and controlled by the application itself. The reason is because you want to display the other players' cards but the local player shouldn't be allowed to touch them. Plus, you need to be able to "undo" actions if the player puts a card on a stack and another player remotely beat them before the client received the information.

I think you realize probably the trickiest issue here, which is that the client can perform the logic to be the most responsive, but the server has to validate all of the rules due to race conditions where 2 clients try to place a card on a slot at the same time, and the client has to be able to accept the fact that the server can cancel his move.
Gillius's Programming