CSCE-315: Programming Studio (Fall 2013)

Project 2: Reversi Online

Updates

  1. [10/28] Under Games (Jump to the section) the following change was made (AI-AI games).
    Also, the game difficulty in this case should be HARD (for both sides) The game difficulty of both should be configurable through the command line argument of the AI-AI command.
  2. [10/09] UNDO must be implemented. REDO is optional.
  3. [10/02] AI-AI option updated.
  4. Updates will be posted here.
  5. The default language is C++. Ask instructor for permission to use a different language.

Team configuration

The team will be the same as project 1, except for a small number of reshuffles. See course web page for details.

In a nutshell

The game you will implement is "Reversi". See Wikipedia entry on Reversi for game rules. Also, there are plenty of online versions that you can play (there are Chrome apps as well).

There are three main parts of the project:

  1. Design and implement the basic game playing mechanism and an AI algorithm to play against humans and other AI.
  2. Design and implement a client-server protocol so that humans can connect to the game server and play the game online. Implement the server and use telent as the client for initial test.
  3. Design and implement a GUI-based client to connect to your game server and play the game.

Here are some additional requirements:

  • For this project, using the unix environment for programming will be more convenient, in terms of socket programming, etc. However, developing in the unix environment is optional, and you will get 5% extra credit for developing in the unix environment (CSE unix servers).
  • We will use the SCRUM method and each of your submissions should be accompanied by SCRUM backlogs and the burndown chart, as well as the code and other documentation.

Reversi Game Play

Here are some ground rules:
  • The game is played on an 8x8 grid.
  • Each row is named 1, 2, 3, ... , 8.
  • Each column is named a, b, c, ... ,h.
  • The initial state is shown below. 'O' is white and '@' is black: d4 white, e4 black, d5 black, e5 white.
      _ _ _ _ _ _ _ _
    1|_|_|_|_|_|_|_|_|
    2|_|_|_|_|_|_|_|_|
    3|_|_|_|_|_|_|_|_|
    4|_|_|_|O|@|_|_|_|
    5|_|_|_|@|O|_|_|_|
    6|_|_|_|_|_|_|_|_|
    7|_|_|_|_|_|_|_|_|
    8|_|_|_|_|_|_|_|_|
      a b c d e f g h
    
  • If the white player goes first, it can play c5, d6, f4, and e3.

Reversi Client-Server Protocol

The communication will be through simple ASCII text. All commands should be case insensitive. The commands are pretty simple.

expr ::= command | move | comment
command
 
 
::= EXIT | DISPLAY
| difficulty
| UNDO
| REDO (optional)
| HUMAN-AI|AI-AI <server> <port> difficulty difficulty
difficulty ::= EASY|MEDIUM|HARD
move ::= column row
comment ::= ; *
column ::= a | b | c | d | e | f | g | h
row ::= 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8
digit ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
server ::= IP address or hostname
port ::= digit { digit }

The commands should function as follows:
  • EXIT: exit and disconnect from the server
  • DISPLAY: toggles board display
  • EASY | MEDIUM | HARD: selects AI difficulty
  • UNDO: undo AI's move and your last move. Up to 10 UNDO's should be supported.
  • HUMAN-AI : human client against server AI
  • AI-AI <server> <port> difficulty difficulty: this server's AI against another server's AI (difficulty of both specified, respectively)
    • This server connects as a client.
    • This server will take the place of a human, so it will enter HUMAN-AI, WHITE, etc. to establish the initial game.

The server will show these messages to the user:

ack ::= WELCOME | OK | move | ILLEGAL | comment
move ::= column row
column ::= a | b | c | d | e | f | g | h
row ::= 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8
comment ::= ; *

The server will always acknowledge the client's input with OK

An unused port should be used for the server. The entire interface should be accessable using telnet, using plain ASCII text. You have to be extra cautious with your code since your server can easily become a security hole. Before you print anything that came from the client or the server, you have to first check if these are printable characters, and make sure the length of the input is within your input buffer size.

An example is shown below. Bold is server, italic is client). Text following ";" are comments and they are simply displayed as they are received and no further action is taken (comments on the far right column are mine, just to explain it a bit). "_" at the end is the cursor waiting for the user input.

WELCOME
WHITE			; choose side
OK			; server confirms user's choice
HUMAN-AI		; choose game mode
OK			; server confirms user's choice
EASY			; set up AI difficulty
OK			; server confirms user's choice
DISPLAY
OK 			; server confirms user's choice

;  _ _ _ _ _ _ _ _
;1|_|_|_|_|_|_|_|_|
;2|_|_|_|_|_|_|_|_|
;3|_|_|_|_|_|_|_|_|
;4|_|_|_|O|@|_|_|_|
;5|_|_|_|@|O|_|_|_|
;6|_|_|_|_|_|_|_|_|
;7|_|_|_|_|_|_|_|_|
;8|_|_|_|_|_|_|_|_|
;  a b c d e f g h
e3  
OK
f3				; server tells you which move it made

;  _ _ _ _ _ _ _ _
;1|_|_|_|_|_|_|_|_|
;2|_|_|_|_|_|_|_|_|
;3|_|_|_|_|O|@|_|_|
;4|_|_|_|O|@|_|_|_|
;5|_|_|_|@|O|_|_|_|
;6|_|_|_|_|_|_|_|_|
;7|_|_|_|_|_|_|_|_|
;8|_|_|_|_|_|_|_|_|
;  a b c d e f g h
g1 
ILLEGAL

;  _ _ _ _ _ _ _ _
;1|_|_|_|_|_|_|_|_|
;2|_|_|_|_|_|_|_|_|
;3|_|_|_|_|O|@|_|_|
;4|_|_|_|O|@|_|_|_|
;5|_|_|_|@|O|_|_|_|
;6|_|_|_|_|_|_|_|_|
;7|_|_|_|_|_|_|_|_|
;8|_|_|_|_|_|_|_|_|
;  a b c d e f g h
_

Reversi Client

Initially telnet will be used as the client, so there's no need to write the client.
telnet <hostname> <port>
or use putty with the "telnet" protocol.

Later on, you will write a stand-alone application that connects to the server using a GUI interface. The GUI interface should support all the functionality described in the client-server protocol.

The GUI has to be able to display the AI-AI games as well as HUMAN-AI games. For the AI-AI games, the first server you connect to will tell you its move and then redirect the move from the second server to you so that you know what moves were made.

Games

The server can either play with a human player or when the human requests, it can also connect to another server and play AI vs. AI.

For the human vs. AI game, human always goes first.

In case of the AI vs. AI game, specific rules must be followed:

  • The server that is initing contact will play the role of the client (it will send "HUMAN-AI" to the server as the game type), thus it will go first. For this case, to simplify matters, the client side should always start out with white.
  • Also, the game difficulty in this case should be HARD (for both sides) The game difficulty of both should be configurable through the command line argument of the AI-AI command.

Project Organization

This project will be approached by trying to follow an approach similar to one that would be used in an agile development environment. Due to team size, and even more significant, due to time constraints, we will not be able to follow a "real" agile approach, but we will try to capture some of the themes.

We will use an iterative approach to this assignment. Your team will be asked to implement the program over three "sprint" iterations, each just over a few days in length. At the end of each iteration, your team should have a complete, working program feature set. More features and functionality should be added at each iteration. In addition, you are to keep a backlog, a burndown chart, and hold SCRUM meetings (almost everyday). Each of these will be discussed below.

The following will be the project schedule:

  1. Project Assigned
  2. Product backlog and initial burndown chart created
  3. Sprint 1 backlog created (game mechanics and server code)
  4. Iteration 1 completed
  5. Sprint 2 backlog created (AI engine)
  6. Iteration 2 completed
  7. Sprint 3 backlog created (GUI and client)
  8. Final Iteration completed

SCRUM tips

Here's an example template of the product backlog:

        Backlog example

And, here's the burndown chart:

        Burndown chart example

Some tips:

        For the project, you should focus on the tasks in the following
        order (near the top is most important). Set up your backlog
        accordingly. Your backlog will be much more detailed than this.

        1. Game mechanics
                - board and game state representation
                - operators
                - operator legality (is a certain move allowed?)
                - move: once a move is made, update the board (flip the
                        intervening tiles)
                - termination condition detection (can any more
                  pieces be placed?)
		- undo/redo
		- show next possible positions
                - game result report (win/lose/draw).

        2. Game Server
                - allows clients to connect
                - can use telnet (e.g., putty, with telnet option) to
                  connect for testing

        3. Game AI
                - initially random player (randomly pick from available
                  moves).
                - min-max with limited depth
                - alpha-beta-pruning-based
                - [optional] more advanced game AI, customize evaluation function. 
	
	4. GUI client
		- allows users to connect to the server using a
		  GUI interface

        As for the burndown chart, you will initially not have
        any data. Use your estimated time for each task and
        during which sprint you will get those done to come up
        with a mock burndown chart.

Grading

There will be a team grade assigned for the project, and like the first project, the team grade will be apportioned out to the individuals. The rough breakdown of team grade is:

20% Agile computing methodology - setting, using, adjusting backlogs and burndown charts, and development log

20% Completeness and quality of the game mechanics

20% Completeness and quality of the AI

15% Completeness and quality of the server interface.

15% Completeness and quality of the GUI client

10% Code style (naming, layout, etc.)

For intermediate submissions (except for design docs), the following rubric will be used.

  • all deliverables submitted 10%
  • all requirements implemented 30% (regardless of function)
  • all requirements function properly 30%
  • code orgaization and readability 15%
  • documentation (input, output, SCRUM activity log, etc.) 15%

Deliverables

The deliverables for each submission will be as follows:
  1. Design documents, SCRUM product log (with initial burndown chart),
    • The design document requirements are the same as Project 1.
    • See the SCRUM tips above for product log format.
  2. Game mechanics code and server code
    • Sprint 1 backlog and burndown chart.
    • Game mechanics code should include fully playable: board display undo, etc. Assume a random AI player (AI choosed randomly among available moves).
    • Server code should be fully functional: user can connect to the open port and play a random game. It should implement the full protocol (you may leave out actual AI-related function: game difficulty, ai-ai).
  3. AI engine code
    • sprint 2 backlog and burndown chart.
    • AI engine should at the minimum implement the MIN-MAX algorithm.
    • You should also design and implement an evaluation function to use at the cut-off state (depth limit).
    • Easy, medium, hard should work as intended (hard should beat medium and easy, and medium beat easy).
    • Alpha-beta pruning is optional (5% extra credit).
  4. Final version.
    • GUI client code, sprint 3 backlog and burndown chart.
    • an updated version of your design document
    • post production notes (changes you had to make to your design and why, difficulties, solutions, lessons learned)
    • individual work load distribution (percentage)
    • self-evaluation (briefly discuss how you contributed to the project) and peer evaluation (rate all other team members on the scale of 1 to 5, 5 being best; plus brief comments). Peer evaluation should be submitted individually.
    • Development log.
Original concept/design/most of the text by John Keyser. Modifications by Yoonsuck Choe.