dotsnboxes. overview dots and boxes is played originally with the use of paper, pen and 2 players....

26
DOTSNBOXES

Upload: marian-rich

Post on 08-Jan-2018

214 views

Category:

Documents


1 download

DESCRIPTION

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

TRANSCRIPT

Page 1: 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

DOTSNBOXES

Page 2: 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

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.

Page 3: 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

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

Page 4: 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

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

Page 5: 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

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).

Page 6: 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

Network Interface/Infrastructure

Client Server

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 sidemodule

Server sidemodule

ClientNetworkInterface ServerNetworkInterface

Packet

Page 7: 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

Network Interface/Infrastructure

Packet StructureType : byteHeader

Body

ConnectResponseClientIDPlayer1NamePlayer2Name

CreateGameSuccessPortNumberGameNamePlayer1NamePlayer2Name

PlayerTurnPlayerID

Page 8: 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

GameForm

Lobby Server

System Block Diagram

Thread

Socket

s User

Network Interface

s User

s User

TcpListener

LoginLoginLobbyForm

Client Server

Game ServerTcpListener

LoginLoginLoginForm

s Player2

s Player1

Port 50000

Ports 51000+GameForm

List

Page 9: 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

GameForm

Lobby Server

Connecting

GetStream

Socket

s User1

Network Interface

s User2

TcpListener

LoginLobbyForm1

Client Server

Game ServerTcpListener

LoginLoginForm1

s Player2

s Player1

Port 50000

Ports 51000+GameForm

List

User1 Thread

User2 Thread

Example

TcpClient

Neutral Thread

LoginForm1 BinaryReader

BinaryWriter

TcpClientGetStream

Page 10: 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

Disconnect HandlingClient Server

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 > 0BinaryWriter

BinaryWriterBinaryReader

BinaryReader

Page 11: 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

0

Lobby Server

Game Server

SocketException

Attempting to reconnect . . .

0

GameForm

Disconnect Handling

Neutral Thread

Socket

s User1

Network Interface

s User2

Lobby Form

LobbyForm

Client Server

Login Form

LoginForm

s Player1GameForm

User1 Thread

User2 Thread

Login Form

0

LoginForm

s Player2

You win bydefault.

Example

0

Page 12: 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

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

Page 13: 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

Screenshots - ClientClient Without a Server to Connect to will retry to Connect.

Page 14: 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

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

Page 15: 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

Screenshots - LobbyOnce connected a lobby will show Games and Players on the Server.

Currently No Games

There is only currentlyone player

Page 16: 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

Screenshots - LobbyEntering 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

Page 17: 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

Screenshots - LobbyWhen 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

Page 18: 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

Screenshots - ClientBoth Users will have a game console like the one below.

Moving the mouse aroundWill highlight clickable spots for User selection

Page 19: 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

Screenshots - ClientThe User can highlightover edges and the boxeswill light up.

Once a User selects a linethe server will register the click and it will be the otherplayer’s turn if it’s nota box creation.

Page 20: 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

Screenshots - ClientAfter boxes are createdthey light up with the players texture.

The Score is shown to theright.

Page 21: 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

Screenshots - ClientOnce a user wins the gameThey will see a flashinghappy face..

As for the loser…

Page 22: 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

Screenshots - ClientThe Loser gets a flashing Sad face.

Both Users now have to click the EXIT button to return back to the lobby.

Page 23: 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

Screenshots - Client

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

Page 24: 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

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

Page 25: 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

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.

Page 26: 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

Questions?