CPS 108, Fall 2001 - OOGA » Group Members: Albert Lee, Steven Poloni, Matthew Yang
First Deliverable - 11/2/2001
Member Titles: Chief Architect: Steven Poloni
Chief Programmer: Albert Lee
Chief Documentarian: Matthew Yang
Guaranteed Implementation: Tic-Tac-Toe
Connect Four
Chomp
Possible Future Implementation: Sliding N-Puzzle
Dots
Black Box
Bejeweled
Architecture: All of our games will have three characteristics in common:
  • Its contents, such as the state of a game
  • Its visual appearance (the GUI)
  • Its behavior (reaction to player moves)

These characteristics will be realized through the Model-View-Controller design pattern (MVC). MVC consists of three objects. The Model is the application object, the View is its screen presentation, and the Controller defines the way the user interface reacts to screen input. MVC decouples views and models by establishing a subscribe/notify protocol bewteen them. A view must ensure that its appearance reflects the state of the model. Whenever the model's data changes, the model notifies views that depend on it. In response, each view gets an opportunity to update itself. The model communicates with its views when its values change, and the views communicate with the model to access these values. This approach lets you attach multiple views to a model to provide different representations. You can also create new views for a model without rewriting it.

To come up with a design for our overall game architecture, we first implemented Tic-Tac-Toe without taking any sort of general architecture into consideration. We did this in order to get a feel of what is involved in programming a game. In our use of the MVC design pattern, each game will implement the following two classes:

  • The GameModel, which stores the contents or state of the game;
  • The GameView, which displays the contents, handles user input, and controls the flow of the game (i.e., taking turns between players).
As you can see, we have decided to encapsulate both the View and Controller in the GameView class. This design decision came while we were trying to implement Tic-Tac-Toe. When we tried to use a separate controller, it only seemed to get in the way. Our Player representations were directly interacting with the View, so it made sense to place them in the View instead of placing them in the controller. What we decided, at least at this point in our project, is that these games do not warrant a separate controller. The View and Control shall be co-located. The GameModel and GameView will communicate mostly via inner classes and message adapters (i.e., via java.awt.event.*). This is basically a kind of "distributed controller" since each inner class and message adapter shares in the role of the controller.

We will also provide classes that represent common functionality in our games. For example, games such as Chomp, Connect Four, Dots, Tic-Tac-Toe, etc, all share several common characteristics which we can exploit. First, all of these games are a competition between two players - one being human and the other being either human or "machine" (an A.I.). The controller in these cases will basically only be responsible for delegating the turns between the two players and controlling the flow of the game. Our first idea would be to include code such as the following:

public void nextPlayer() 
{
   if (gameOver()) showWinner();
      
      // switch players
      else 
      {  
         if (nextPlayer == player1) 
         {
            nextPlayer = player2;
         }
         else 
         {
            nextPlayer = player1;
         }
         nextPlayer.takeTurn(); 
      } 
}
in order to facilitate game play. Also, each game uses a board. We will have a generic GameBoard class that will faciliate the representation of a typical game board.

Key Classes: Some of the key classes in our game architecture are the Player class, the GameBoard class, and the GameTile class.

A GameBoard can be leveraged by any game that is played on a grid-like surface. A GameBoard consists of any number of GameTiles. A programmer will be able to easily change the look and feel of the board using setColor(), setSize(), and other visual-enhancing functions.

A GameTile can be a button to click on (like in Tic-Tac-Toe), a tile to simply display something, or anything else that can have ActionListeners associated with it. This makes the GameBoard class flexible across different games because each GameTile will be able to perform a variety of tasks depending on the game.

A Player class is useful for games supporting two or more players. Each Player object can make a move, or take it's turn, using an abstract takeTurn() method. In this way, we can easily incorporate different players into game, such as a network player, or even an artifical intelligent (AI) player.

Time Table: Friday, November 2, 2001: prototype for Tic-Tac-Toe finished
Saturday, November 3, 2001: Coding...
Sunday, November 4, 2001: Coding...
Monday, November 5, 2001: TicTacToe done
Tuesday, November 6, 2001: Coding...
Wednesday, November 7, 2001: Prototype for Connect Four
Thursday, November 8, 2001: Prototype for Chomp
Friday, November 9, 2001: Prototypes for all games finished. All games are in "working" condition.
Saturday, November 10, 2001: Debug all code.
Sunday, November 10, 2001: Finish Documentation on all games.
Monday, November 11, 2001: Final Project finished, submitted for grade
Screenshot: