Server Based Law General Essay

Print   

02 Nov 2017

Disclaimer:
This essay has been written and submitted by students and is not an example of our work. Please click this link to view samples of our professional work witten by our professional essay writers. Any opinions, findings, conclusions or recommendations expressed in this material are those of the authors and do not necessarily reflect the views of EssayCompany.

1. Introduction

This document defines how to play a Tic-tac-toe game over TMPP (TMPP is temporary Protocol).

It is quite common to play games over Servers. Since Tic-tac-toe is a well-known and simple game, it's a good example for a server-based game protocol.

2. Requirements

This document addresses the requirements for a game protocol as defined by Multi-User Gaming. In particular this consists of:

Game roles

Match state

Turns

Match configuration

Conditions for interrupting and terminating a match

3. Discovering Support

An entity implementing this protocol MUST also support Multi-User Gaming and answer to disco requests accordingly including both the Multi-User Gaming and the game elements in the response.

Example 1. Service Informs ABC That It is Capable of Hosting Tic-tac-toe

<iq type='result'

from='www.website.org’

id='disco1'

to='[email protected]/garden'>

<query xmlns='http://website.org/protocol/disco#info'>

...

<feature var='http://website.org/protocol/mug'/>

<feature var='http://website.org/protocol/mug/tictactoe'/>

...

</query>

</iq>

4. Game Roles

A Tic-tac-toe game uses two game roles, "x" and "o". Both roles have to be assigned to exactly one player to start a match. If one role gets unassigned or a player gets unavailable the match has to be paused.

5. Match Configuration

A service SHOULD offer a configuration form with the following options:

Starting role ("mug/tictactoe#config_first")

Size of the board ("mug/tictactoe#config_rows" and "mug/tictactoe#config_cols")

The number of marks in a row needed to win ("mug/tictactoe#config_first")

An implementation MUST be able to handle the board with three cols and rows and three respective marks to win. Everything beyond that is OPTIONAL.

Example 2. Service Sends Configuration Form

<iq from='[email protected]'

id='config1'

to='[email protected]/garden'

type='result'>

<query xmlns='http://website.org/protocol/mug#owner'>

<options>

<x xmlns='website:x:data' type='form'>

<title>Tic-tac-toe Room</title>

...

</x>

<options xmlns='http://website.org/protocol/mug/tictactoe'>

<x xmlns='website:x:data' type='form'>

<title>Configuration for Tic-tac-toe</title>

<instructions>

Below you can see the default configuration.

To accept the default configuration, click OK.

To select a different configuration, please complete this form.

</instructions>

<field var='FORM_TYPE' type='hidden'>

<value>http://website.org/protocol/mug/tictactoe#tictactoeconfig</value>

</field>

<field label='Number of rows' var='mug/tictactoe#config_rows' type='list-single'>

<value>3</value>

<option label='3'><value>3</value></option>

<option label='4'><value>4</value></option>

<option label='5'><value>5</value></option>

<option label='6'><value>6</value></option>

<option label='7'><value>7</value></option>

<option label='8'><value>8</value></option>

<option label='9'><value>9</value></option>

<option label='10'><value>10</value></option>

</field>

<field label='Number of cols' var='mug/tictactoe#config_cols' type='list-single'>

<value>3</value>

<option label='3'><value>3</value></option>

<option label='4'><value>4</value></option>

<option label='5'><value>5</value></option>

<option label='6'><value>6</value></option>

<option label='7'><value>7</value></option>

<option label='8'><value>8</value></option>

<option label='9'><value>9</value></option>

<option label='10'><value>10</value></option>

</field>

<field label='Strike' var='mug/tictactoe#config_strike' type='list-single'>

<value>3</value>

<option label='3'><value>3</value></option>

<option label='4'><value>4</value></option>

<option label='5'><value>5</value></option>

<option label='6'><value>6</value></option>

<option label='7'><value>7</value></option>

<option label='8'><value>8</value></option>

<option label='9'><value>9</value></option>

<option label='10'><value>10</value></option>

</field>

<field label='Select a role who start the game' var='mug/tictactoe#config_first' type='list-single'>

<value>x</value>

<option label='x'><value>x</value></option>

<option label='o'><value>o</value></option>

</field>

</x>

</options>

</options>

</query>

</iq>

Submitting a strike option value bigger than the number of rows or columns SHOULD result in error.

6. Match State

The state in a Tic-tac-toe match represents the match configuration, the player who makes the next turn and the current state of the board. Every state is distributed to all occupants.

Example 3. Service Sends Start State

<presence

from='[email protected]'

to='[email protected]/garden'>

<game xmlns='http://website.org/protocol/mug'>

<status>inactive</status>

<state xmlns='http://website.org/protocol/mug/tictactoe'>

<rows>3</rows>

<cols>3</cols>

<strike>3</strike>

<next>x</next>

<board/>

</state>

</game>

</presence>

After a valid turn, the state gets updated with the corresponding mark.

Example 4. Service Sends Mid-Game State

<presence

from='[email protected]'

to='[email protected]/garden'>

<game xmlns='http://website.org/protocol/mug'>

<status>active</status>

<state xmlns='http://website.org/protocol/mug/tictactoe'>

<rows>3</rows>

<cols>3</cols>

<strike>3</strike>

<next>o</next>

<board>

<field row='1' col='1'>x</field>

<field row='2' col='1'>o</field>

<field row='2' col='2'>x</field>

<field row='1' col='3'>o</field>

<field row='2' col='3'>x</field>

</board>

</state>

</game>

The match is considered terminated when the board is full or when one player reaches the number of respective marks as defined by the strike option. After termination the service broadcasts the final state including either a <draw> or <won> (including a game role) element to indicate the resulting score and the initial state of the next round.

Example 5. Service Sends Draw State

<presence

from='[email protected]'

to='[email protected]/garden'>

<game xmlns='http://website.org/protocol/mug'>

<status>inactive</status>

<state xmlns='http://website.org/protocol/mug/tictactoe'>

<rows>3</rows>

<cols>3</cols>

<strike>3</strike>

<next>o</next>

<board/>

<won>x</won>

</state>

</game>

</presence>

7. Turns

During the game, player’s change in turn, each of them MUST send only one move at a time. It MUST possess these attributes:

Table 1: <move/> attributes

Name

Type

Description

'id'

REQUIRED

The number of the move. First move is 1.

'row'

REQUIRED

The horizontal position of the mark.

'col'

REQUIRED

The vertical position of the mark.

Example 6. ABC Sends a Move

<message

to='[email protected]'

from='[email protected]/garden'

type='chat'>

<turn xmlns='http://website.org/protocol/mug#user'>

<move

xmlns='http://website.org/protocol/mug/tictactoe'

row='3'

col='2'

id='7'/>

</turn>

</message>

8. Security Considerations

The author is not aware of any security issues introduced by this protocol extension.

9. FLOW CHART

Server

Create a server socket.

Accept connection from the first player and notify the player is Player 1 with token X.

Accept connection from the second player and notify the player is Player 2 with token O. Start a thread for the session.

Player 1

1. Initialize user interface.

2. Request connection to the server and know which token to use from the server.

3. Get the start signal from the server.

4. Wait for the player to mark a cell, send the cell's row and column index to the server.

5. Receive status from the server.

6. If WIN, display the winner; if player 2 wins, receive the last move from player 2. Break the loop

7. If DRAW, display game is over; break the loop.

8. If CONTINUE, receive player 2's selected row and column index and mark the cell for player 2.

Player 2

1. Initialize user interface.

2. Request connection to the server and know which token to use from the server.

3. Receive status from the server.

4. If WIN, display the winner. If player 1 wins, receive player 1's last move, and break the loop.

5. If DRAW, display game is over, and receive player 1's last move, and break the loop.

6. If CONTINUE, receive player 1's selected row and index and mark the cell for player 1.

7. Wait for the player to move, and send the selected row and column to the server.

Handle a session:

1. Tell player 1 to start.

2. Receive row and column of the selected cell from Player 1.

3. Determine the game status (WIN, DRAW, CONTINUE). If player 1 wins, or drawn, send the status (PLAYER1_WON, DRAW) to both players and send player 1's move to player 2. Exit.

.

4. If CONTINUE, notify player 2 to take the turn, and send player 1's newly selected row and column index to player 2.

5. Receive row and column of the selected cell from player 2.

6. If player 2 wins, send the status (PLAYER2_WON) to both players, and send player 2's move to player 1. Exit.

7. If CONTINUE, send the status, and send player 2's newly selected row and column index to Player 1.



rev

Our Service Portfolio

jb

Want To Place An Order Quickly?

Then shoot us a message on Whatsapp, WeChat or Gmail. We are available 24/7 to assist you.

whatsapp

Do not panic, you are at the right place

jb

Visit Our essay writting help page to get all the details and guidence on availing our assiatance service.

Get 20% Discount, Now
£19 £14/ Per Page
14 days delivery time

Our writting assistance service is undoubtedly one of the most affordable writting assistance services and we have highly qualified professionls to help you with your work. So what are you waiting for, click below to order now.

Get An Instant Quote

ORDER TODAY!

Our experts are ready to assist you, call us to get a free quote or order now to get succeed in your academics writing.

Get a Free Quote Order Now