Presentation is loading. Please wait.

Presentation is loading. Please wait.

DOTSNBOXES. Overview Dots and Boxes is played originally with the use of paper, pen and 2 players. The Game board is a matrix of points and vary in size.

Similar presentations


Presentation on theme: "DOTSNBOXES. Overview Dots and Boxes is played originally with the use of paper, pen and 2 players. The Game board is a matrix of points and vary in size."— Presentation transcript:

1 DOTSNBOXES

2 Overview Dots and Boxes is played originally with the use of paper, pen and 2 players. The Game board is a matrix of points and vary in size. However an odd number of squares is desired to reduce a tie. Players draw one line at a time. If they complete a square they get to put their initial in the box and go again. Ideally the goal of the game is to get as many boxes with your initial in it. This is ideally done with a long collection of boxes collected one after the other.

3 Requirements Design a graphical user interface Create a multi-threaded client/server application that utilizes stream sockets Handle disconnects on either the client or server side Server to support multiple game instances Appropriate edit-checking on user-submitted data

4 Additional Features Login screen for clients to choose their own usernames to uniquely identify themselves. Lobby area, to provide: – a list of all users currently online – a list of all active/pending games Shows the player(s) currently in the game Users may create new games or join games with an empty spot available Users may play multiple games simultaneously

5 Gameplay Logic At initialization:  Assign each edge an EdgeID, each box a BoxID.  For each box, assign its edges (Top, Bottom, Left, Right) the appropriate EdgeID.  For each edge, assign its boxes (max 2) the appropriate BoxID. During Gameplay:  For each edge that is drawn on by the players, 1.Flag the edges as ‘exists’. 2.Check the edge’s associated BoxID’s (up to 2) and check which edges exist.  If all four edges exist, then draw the box(es).

6 Network Interface/Infrastructure ClientServer  ClientNetworkInterface – Sets up a TcpClient, given the hostname and port  ServerNetworkInterface – Sets up a NetworkStream, given a socket  Mechanized Packets to send data across the connection  2 methods using BinaryFormatter: Convert serialized byte array to Packet Convert Packet to serialized byte array Client side module Server side module ClientNetworkInterfaceServerNetworkInterface Packet

7 Network Interface/Infrastructure Packet Structure Type : byte Header Body ConnectResponse ClientID Player1Name Player2Name CreateGameSuccess PortNumber GameName Player1Name Player2Name PlayerTurn PlayerID

8 Game Form Lobby Server System Block Diagram Thread Socket s User Network Interface s User s TcpListener Login Lobby Form Client Server Game Server TcpListener Login Form s Player2 s Player1 Port 50000 Ports 51000+ Game Form List

9 Game Form Lobby Server Connecting GetStream Socket s User1 Network Interface s User2 TcpListener Login Lobby Form1 Client Server Game Server TcpListener Login Form1 s Player2 s Player1 Port 50000 Ports 51000+ Game Form List User1 Thread User2 Thread Example TcpClient Neutral Thread Login Form1 BinaryReader BinaryWriter TcpClient GetStream

10 Disconnect Handling ClientServer ClientNetworkInterface ServerNetworkInterface Packet  bytes (b) – The size in bytes of the packet.  BinaryWriter (Success) – Write method sends a packet of size b across the connection.  BinaryWriter (Failure) – Write method throws a System.IO.IOException exception.  BinaryReader (Success) – Read method accepts a packet and returns its size b.  BinaryReader (Failure) – Read method returns 0 upon disconnection. b > 0 BinaryWriter BinaryReader

11 0 Lobby Server Game Server SocketException Attempting to reconnect... 0 Game Form Disconnect Handling Neutral Thread Socket s User1 Network Interface s User2 Lobby Form Lobby Form ClientServer Login Form Login Form s Player1 Game Form User1 Thread User2 Thread Login Form 0 Login Form s Player2 You win by default. Example 0

12 Error Checking Prevent duplicate users Prevent duplicate game names Prevent user from joining his own game Prevent user from joining a full game Prevent user from joining a game that no longer exists Prevent multiple servers on the same port Prevent erroneous user input Handle disconnects accordingly

13 Screenshots - Client Client Without a Server to Connect to will retry to Connect.

14 Screenshots - Client Once the Server is stated, the Client will automatically connect!

15 Screenshots - Lobby Once connected a lobby will show Games and Players on the Server. Currently No Games There is only currently one player

16 Screenshots - Lobby Entering a GAME name in the box and clicking “Create Game” will add a new game to the lobby and start you in a new game of DotsNBoxes. One Game is Waiting Players myNewGame

17 Screenshots - Lobby When more games are created, users wanting to play a game can see the Games in the Lobby. If a User Clicks “Join” they will start a game with the other player

18 Screenshots - Client Both Users will have a game console like the one below. Moving the mouse around Will highlight clickable spots for User selection

19 Screenshots - Client The User can highlight over edges and the boxes will light up. Once a User selects a line the server will register the click and it will be the other player’s turn if it’s not a box creation.

20 Screenshots - Client After boxes are created they light up with the players texture. The Score is shown to the right.

21 Screenshots - Client Once a user wins the game They will see a flashing happy face.. As for the loser…

22 Screenshots - Client The Loser gets a flashing Sad face. Both Users now have to click the EXIT button to return back to the lobby.

23 Screenshots - Client Users may play multiple games simultaneously by going back to the lobby and creating/joining new games.

24 Screenshots - Server Throughout all the connections and game interactions, the server shows information being written to a console output.

25 Obstacles – Unexpected Game Over What happens if a player quits in the middle of a game? This will automatically send a message to the user still in game that the user has ended the game and they may click “Exit” to return to the lobby. Sadly... You will not see the happy face for this type of win.

26 Questions?


Download ppt "DOTSNBOXES. Overview Dots and Boxes is played originally with the use of paper, pen and 2 players. The Game board is a matrix of points and vary in size."

Similar presentations


Ads by Google