This assignment is out of 60 points.
Paper copies of your work must be handed in to the CS 1025 locker (using the assignment submission form) and electronic copies should be submited via the usual Computer Science Department electronic assignment submission system.
Paper copies of your work must be handed in to the CS 1025 locker and electronic copies should be submited via the usual Computer Science Department electronic assignment submission system. Detailed instructions on how to submit an assignment are located on the How to Submit Assignments page.
Please see the course outline for information on late penalties and the rules of ethical conduct.
In this assignment you will create a graphical user interface for a Reversi game. A Reversi game-playing engine will be posted once the cut-off for handing in Assignment 3 has passed.
Create two classes ReversiGUI_Board and ReversiGUI_Square. The class ReversiGUI_Square should extend the class JButton from Swing, and the class ReversiGUI_Board should extend extend the class JFrame.
The class ReversiGUI_Square should have methods:
The class ReversiGUI_Board should give a nrows x ncols grid of ReversiGUI_Squares. The representation should include
Add a MouseEventListener to ReversiGUI_Square so that clicks on a square cycle through the three possibilities empty square, white piece, black piece. That is, one click changes from empty square to white piece. A second click changes from white piece to black piece. A third click changes from plack piece to empty. A fourth click changes to white piece again, etc.
Modify the constructor for ReversiGUI_Square so that it takes a ReversiGUI_Board object as a parameter.
Modify the MouseEventListener on the squares so that mouse clicks cause the entire row and entire column of the square (i.e. the cross of all nrows + ncols - 1 squares) cycle through the three possibilities (as in question 2).
Modify ReversiGUI_Board and ReversiGUI_Square to
Modify your program so that after the human player moves, it consults a game-playing engine to find the move that the computer will make. A Reversi game-playing engine will be posted after the cut-off for Assignment 3 has passed (that is, on Monday October 27).
Note that this program orgnization does not allow the computer player to "think" while the human player is thinking. A more advanced game would allow the computer player to explore the game tree as a parallel thread.
You do not have to do these, but they might be fun to try. They require ideas not covered in class, but I would be happy to discuss them with you and get you started.
Modify your program so that it displays pictures instead of text labels on the squares.
Modify your program so that there is a Java interface ReversiUI and that the ReversiGUI_Board and a new ReversiTextBoard are now classes with that interface. Modify your game so that it takes a ReversiUI object and plays the game without knowing whether it is using a text or graphical user interface.
Modify your program so that it explores the tree in parallel with the human player thinking.