Java Program: Qubic Master

Description:

The project will involve creating an interactive game that allows the user to play Qubic (4 by 4 by 4 tic-tactoe) against the computer. Your solution must implement at least two nontrivial levels of play (e.g., intermediate and advanced) and one of those must involve implementing the recursive look-ahead strategy discussed in class. Your two levels of play must be substantially different. You cannot, for example, simply change the maximum depth of the recursion. Your program must also provide at least two views of the Qubic board that show each square at least once. In terms of controls, the user should be allowed to click on a square in any view to move to that square. There should also be controls for starting a new game, quitting and undoing a move. The undo command should undo the user’s most recent move and let the user make another choice. It should be possible to call undo several times in a row, potentially undoing all the way back to an empty board.

Criteria:

  • You must implement a Java program that allows a user to play Qubic with the computer. You must use the Swing components to implement your user interface elements.
  • Your user interface must include at least three views of the Qubic game. At least two of these views must show the squares of the Qubic board and must allow the user to select squares by clicking on them. Examples are a 4-plane flat view, a 4-plane 3-dimensional view and a “sequence of moves” view that shows the history of moves made by the computer and the user.
  • Your program must allow the user to decide whether to go first or second.
  • Your program must keep track of the Qubic game state, allowing only legal moves and reporting the winner.
  • The user must be able to select moves by clicking on a square displayed in a view.
  • The user must be able to undo moves all the way back to the beginning of play. When a user selects undo, both the most recent computer move and the most recent user move are to be reversed and play reverts to the game state when the user last had a turn.
  • The program must implement at least three distinct levels of play on the part of the computer. These must be nontrivial and distinct strategies, not just just random play or minor variations of a single strategy. The user must be able to select which strategy to play against.
  • The user must be able to save the current game to a file. The user also should be able to open a previously saved game from a file. Each request should bring up a file dialog box.
  • The program must have a menu bar with a “File” menu including commands “New”, “Open”, “Save” and “Exit”. If the user is in the middle of a game and either asks for a new game or requests an exit from the program, the user should be asked whether or not to save the current game. The user should have the option of canceling the request or asking to save the file, which should bring up the file dialog.
  • The user must be able to select the “close” button in the upper-right corner of the frame and if the user is in the middle of a game, the user should be asked whether or not to save the current game, as described in the previous item.
  • One of your strategies must be the recursive look-ahead strategy described in the next section.
  • Your program must have another menu that allows the user to select the level of play. Only one level of play can be selected at a time. It must be possible to change the level of play in the middle of a game. For example, a user could play against a novice that makes bad moves and then switch to playing against the expert. The expert can’t redo the previous moves, but it can take over where the novice left off and make the best of the current configuration in deciding future moves.

Recursive look-ahead stratey:

Recursive look-ahead strategy Your Qubic program must implement a strategy described in class where the computer searches for a guaranteed winning strategy that involves forcing the user to make a series of moves that leave the computer ultimately with a win. You are to implement this algorithm recursively. The basic algorithm can be described as follows:

  method to search for a guaranteed win:
  {
    if (the computer has a simple win, a 3-in-a-row)
      you’ve found the guaranteed win
    else if (the user does not have a simple win) { 
      for (every row with just 2 computer pieces) 
        for (each empty square in the row) {
          pretend that the computer takes the square. 
          pretend that the user takes the other square in the row. 
          recursively call to see if this leads to a guaranteed win. 
          if (win was found) 
            remember winning move and return; 
          undo pretend computer move 
          undo pretend user move
        }
    }
  }

Extra Credit:

The last 20 points of the project will be awarded based on the implementation of additional features. You are allowed to pursue any reasonable extension to the program that interests your group.

Our group did several items for extra credit. The biggest being creating a new variant of the game called limited. When playing limited there are only a certain number of pieces allowed per player. When the limit of pieces is reached the first piece played is removed to place another piece.

Conclusion:

This was my first and best big team project. As a result of this project I was able to gain team members for many of my future group work at school. We managed to be the perfect team; work was done organized, early, and well. We managed to acomplish more than pretty much any other group, and in a much more organized fashion.

My main focus for this project was the GUI. I decided on each of the views to use, and figured out how to interface them with the model. This was often a challenge as the data structure used by the model was not convinent to be used by the view most of the time. I also would help debug other group member's code.

Links:

Comments: [Add a Comment]

Creative Commons License   This webpage and all of its contents are licensed under a
Creative Commons License by Dr-EagleEyes.com.