Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Undergrad Team Project: Developing TCP-based 'Sorry!' Board Game, Study Guides, Projects, Research of Computer Science

An undergraduate team project where students developed a networked version of the classic board game 'sorry!' using tcp protocol and java classes. Details on application protocol, client-server messages, and instructions for compiling and running the application in linux/unix and windows environments.

Typology: Study Guides, Projects, Research

2009/2010

Uploaded on 03/28/2010

koofers-user-t3e
koofers-user-t3e 🇺🇸

5

(2)

10 documents

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Undergraduate Team Project
4003-420-02
Data Communications and Networks I
Erik Corwin
James Loomis
Winter Quarter 2009
Team Awesome
Our Project is an adaptation of the classic board game, Sorry!
Application Protocol
The network protocol used by our application uses the TCP protocol. We used DataInputStream
and DataOutputStream Java classes, and a Network Proxy pattern, just as we did with the in-class
examples. A character encoded as a byte is used to determine the command. What follows is
determined by the command.
Client to Server Messages
Update 'U' Game State * Update the client with a new game state.
Error 'E' String Report an error to the client. For example, a player
has already been chosen.
Message 'M' String Display a message on the client. For example, the
move the user attempted was invalid, or it is not
their turn.
Server to Client Messages
Join 'J' String, Int Join a named session (or create, if it does not
already exist) as a specific player ID.
Discard 'D' Int, Int Discard a card from a specific hand position
Play 'M' Play ** Display a message on the client. For example, the
move the user attempted was invalid, or it is not
their turn.
List
Sessions
'L'
* The game state is represented as a 2D array of pawns (4x4, integers), an array of cards
(5, integers), and an integer defining which player's turn it currently is.
** A play is represented as a player ID, a card index, and a 2D array, (2x2) consisting of a
pair of { START, END } board spaces.
pf3
pf4
pf5

Partial preview of the text

Download Undergrad Team Project: Developing TCP-based 'Sorry!' Board Game and more Study Guides, Projects, Research Computer Science in PDF only on Docsity!

Undergraduate Team Project

Data Communications and Networks I Erik Corwin James Loomis Winter Quarter 2009 Team Awesome Our Project is an adaptation of the classic board game, Sorry! Application Protocol The network protocol used by our application uses the TCP protocol. We used DataInputStream and DataOutputStream Java classes, and a Network Proxy pattern, just as we did with the in-class examples. A character encoded as a byte is used to determine the command. What follows is determined by the command. Client to Server Messages Update 'U' Game State * Update the client with a new game state. Error 'E' String Report an error to the client. For example, a player has already been chosen. Message 'M' String Display a message on the client. For example, the move the user attempted was invalid, or it is not their turn. Server to Client Messages Join 'J' String, Int Join a named session (or create, if it does not already exist) as a specific player ID. Discard 'D' Int, Int Discard a card from a specific hand position Play 'M' Play ** Display a message on the client. For example, the move the user attempted was invalid, or it is not their turn. List Sessions

'L'

  • The game state is represented as a 2D array of pawns (4x4, integers), an array of cards (5, integers), and an integer defining which player's turn it currently is. ** A play is represented as a player ID, a card index, and a 2D array, (2x2) consisting of a pair of { START, END } board spaces.

Developer's Manual: Linux/UNIX environment: Download sorry-src.jar onto a Linux/Unix based system. To compile the files, you must extract them from the jar. To do this type into the terminal: jar -xvf viagra.jar Once the files are extracted they can be compiled by executing: javac *java This should compile all of the source files. To start the Server, type into the terminal: java SorryServer To start the Client, type into the terminal: java SorryClient Follow the GUI instructions, listed below in the User's Manual section, using the host name and port number you chose for the Server to connect to the Server. Windows environment: Please reference the following URL: http://www.linux.org/dist/download_info.html.

If the host name or port number are incorrect, the user is notified and returned to the Sorry! splash screen. If the connection was successful, the user is prompted to choose either “Join an existing game” or “Create a new game”. If a user wants to create a new game, click “Create a new game” and type the name of the game they want to create, otherwise click “Join an existing game” and choose from the list (if there are any there). After a selection is made, a user can choose what color they want to be (Red, Blue, Yellow, Green). Once all of the choices are made, click Connect. The board is created and displayed to the user. In order to move a piece, click on a card (if its your turn), then click on the piece you want to move. The available moves are shown to the user, once the piece is clicked. The game ends when a user gets all four of their playing pieces to the home circle. Illustration 2 : Game Setup screen Illustration 3 : Sorry! Board

UML Diagram: Sequence Diagram: SERVER CLIENT ViewListener SessionManager ViewProxy ViewListener SorryGame ModelListener SorryState ModelProxy ViewListener Network – TCP SorryUI ModelListener Before joining a session After Joining SorryState copy ModelListener SorryClient SelectSessionUI A Session Server Client 1 Client 2 Server SessionManager (^) (SorryGame, Model)Session TCP connect TCP connect 'L' – list sessions List of existing sessions 'J' – join a session update() 'L' – list sessions List of existing sessions 'J' – join a session update() update() 'P' – make a move update() update() 'P' – make a move update() update() TCP close TCP close update() First player connects; joins a session Second player connects; joins same session Player 1 Moves Player 2 Moves Player 2 disconnects Player 1 disconnects