DRAFT: This module has unpublished changes.

Project Documentation

Project: Rock-Paper-Scissors

 

Introduction:

            It implements the Rock-Paper-Scissor game that a player can play via client program with the server. It uses TCP to communicate between a client program and a sever program.

This is a single player game with the server as the opponent player. The server starts the game after a player is log in using the client program which initiates the connection between client and the server. Once the connection is established the server send a message to client program to let the user know that the game is started. The server randomly chooses one of three shapes and wait for the user’s chosen shape. After getting the message of game Start, the client program prompts the user to choose one of the shape or logout, and send the user command to server. Upon receiving the player’s command, server checks the following to send its decision to client:

  1. Did user take more than 5 seconds to choose a shape?
  2. Is the shape match with the shape that server randomly chose?
  3. Did server won or lost, based on what shape user chose?
  4. Did server want to logout or not?

Finally, the server sends its decision to client about whether the time was out, the game was tie, the user won or lost, and what are the stats of the current the game.

 

Overview:

  1. The client and server successfully connect and communicate with each other using TCP.
  2. The client program prompts the user to type login or help.
  3. If user types help, the client program displays the list of supported commands and a brief description of its function and the syntax of usage.
  4. If user types login, the client program prompts the user to enter his/her name.
  5. The server prints the name of player send by the client log in command.
  6. After receiving player name, server send message, “The game is on!” to notify the user.
  7. Server randomly choose one of the shape and gets the current time.
  8. The client prompts the user to choose on of the shape from Rock, Paper, or Scissor.
  9. Client program waits for the user to type either rock, paper, scissor, or logout.
  10. Client program sends the user input to server program.
  11. The server prints the clients input in server display screen for debugging purpose.
  12. If the input is logout, the server will send the game stat to client program and makes the all the stat record 0, close the connection to this player and wait for the connection from the player again for another session.
  13. If the input is not logout, the server gets the input received time to check whether user took more than 5sec to choose the shape.
  14. If the user took more than 5 seconds to choose the shape, server sends the timeout message to client program and, add 1 to both the total number of game and total number of timeout, choose a shape randomly and get the time.
  15. Client program prompts the user to choose a shape again and sends the players input to server side program.
  16. Server side program again get the time after receiving the player’s input and checks whether player took more than 5 seconds.
  17. If the user replies before 5 second than server check the input with its randomly selected shape to learn whether it’s a tie or not.
  18. The server sends the message “tie” to client program incase they both choose the same shape and randomly chooses another shape but don’t increase the total game number.
  19. After receiving, tie message client side program again prompt the user to choose a shape and sends to the server side.
  20. If it is not tie, then server compares the input with server’s chose shape and makes a decision whether player won or lost and sends the message to client program. It the player wins it increase its total number of win and total number of game.
  21. Finally, it again waits for user input and start the timer by recording a current time.

 

 

User documentation:

  1. Make sure the computer has python installed.
  2. Open the terminal and go to the directory where you have saved tcpServer.py.
  3. Type python tcpServer.py and click on allow if a window pops up.
  4. The server should print “The server is ready to accept request.”
  5. Open another terminal and go to the directory where you have saved clientProgram.py.
  6. Type python clientProgram.py
  7. The client program should print “Choose help or login”
  8. Type help to learn more about the other available commands.
  9. Type login to start the game.
  10. The client program prompts you to “Enter your name to login:”
  11. Type your name and hit enter.
  12. Then you will see the messages “The game is on!” and “Choose rock, paper, scissor, or logout”
  13. Type one the option and hit enter.
  14. If you took more than 5 seconds to send one of the option, it will say “timeout” and again prompt you to choose one of the option.
  15. If you send your choice before 5 seconds and it matches with the server’s chosen shape, it will print “tie” and prompt you to choose a shape again.
  16. If you send you choice before 5 seconds and it is not same as server’s choice then you get the message “Server chose …..., client won” if your shape won the server’s shape, else it prints the message “Serve chose …..., client lost” based on your choice of shape.
  17. If your input is logout instead of rock, paper, or scissor, it will print “Total Game is … and Total Win is ….. and Total time out is ….”
  18. Finally, client program closes the connection with server program.
  19. The server program waits for another player.
  20. Either, start another game with server or hit ctrl + c to stop the server.

 

System documentation:

  1. Protocol: TCP
  2. Server port: 5194
  3. Client program request methods: login, rock, paper, scissor, logout
  4. Server program response messages: “The game is on!”, “timeout”, “tie”, “server choose …, client won”, “server choose …, client lost”, “Total Game is … and Total Win is ….. and Total time out is ….”

 

login method: is to initiate the TCP connection with server and to send player’s name to server program.

rock, paper, and scissor methods: are to send player’s choice to server program.

logout method: is to get game stat and to close the connection.

 

The program uses the conditional statements widely.

 

 

Testing documentation:

Scenario 1:                 

  1. Start tcpServer.py and clientProgram.py
  2. Type anything other than “help” or “login” without quote case sensitive:

Expected output: “Please type either help or login all in small letters.”

Actual output: “Please type either help or login all in small letters.”

  1. Type help:

Expected output: list of commands and its description.

Actual output: lost of commands and its description.

  1. Type login:

Expected output: “Enter your name to login:   “

Actual output: “Enter your name to login:  “

  1. Type any name

Expected output: name printed out on server program screen.

Actual output: name printed out on server program screen.

  1. Type rock, paper, or scissor after 5 seconds:

Expected output: timeout

Actual output: timeout

  1. Type logout after 5 seconds

Expected output: timeout and Total Game is 1 Total Win is 0 and Total timeout is 1

Actual output: timeout and Total Game is 1 Total Win is 0 and Total timeout is 1

 

 

 

Scenario 2:

  1.  Start tcpServer.py and clientProgram.py
  2. Type login:

Expected output: “Enter your name to login:   “

Actual output: “Enter your name to login:  “

  1. Type any name

Expected output: name printed out on server program screen.

Actual output: name printed out on server program screen.

  1. Type rock before 5 seconds:

Expected output: tie, server chose ……, client won, or server chose …, client lost.

Actual output: server chose scissor, client won

  1. Type rock before 5 seconds:

Expected output: tie, server chose ……, client won, or server chose …, client lost.

Actual output: server chose paper, client lost

  1. Type rock before 5 seconds:

Expected output: tie, server chose ……, client won, or server chose …, client lost.

Actual output: server chose paper, client lost

  1. Type logout before 5 seconds:

Expected output: Total Game is 3 Total Win is 1 and Total time out is 0

Actual output: Total Game is 3 Total Win is 1 and Total time out is 0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

DRAFT: This module has unpublished changes.