@@ -0,0 +1,1812 @@
+/*%0A * PCR Homework assignment 7 Due on 13/06/2013%0A * Class to define the state of a Connect Four game %0A * and calculate it's utility function.%0A */%0Apackage hw7;%0A%0A/**%0A *%0A * @authors Iuri Andrade, Alexander Moriaty, Oscar Lima%0A */%0Apublic class GameState %7B%0A%0A  private char%5B%5D%5B%5D stateMatrix;%0A  private static final int ROWS = 6;%0A  private static final int COLUMNS = 7;%0A  private char player;%0A%0A  public GameState() %7B%0A    setInitialState();%0A    player = 'O';%0A  %7D%0A%0A  public boolean dropTile(int col) %7B%0A    int freeRow = getFreeRow(col);%0A    if (freeRow != -1) %7B%0A      stateMatrix%5BfreeRow%5D%5Bcol%5D = player;%0A      nextPlayer();%0A      return true;%0A    %7D%0A    return false;%0A  %7D%0A%0A  private void nextPlayer() %7B%0A    if (player == 'O') %7B%0A      player = 'X';%0A    %7D else %7B%0A      player = 'O';%0A    %7D%0A  %7D%0A%0A  private void setInitialState() %7B%0A    this.stateMatrix = new char%5BROWS%5D%5BCOLUMNS%5D;%0A    for (int i = 0; i %3C ROWS; i++) %7B%0A      for (int j = 0; j %3C COLUMNS; j++) %7B%0A        this.stateMatrix%5Bi%5D%5Bj%5D = ' ';%0A      %7D%0A    %7D%0A  %7D%0A%0A  public int getFreeRow(int col) %7B%0A    if (isColumnFree(col)) %7B%0A      for (int i = 0; i %3C ROWS; i++) %7B%0A        if (this.stateMatrix%5Bi%5D%5Bcol%5D == ' ') %7B%0A          return i;%0A        %7D%0A      %7D%0A    %7D%0A    return -1;%0A  %7D%0A%0A  private boolean isColumnFree(int col) %7B%0A    if (this.stateMatrix%5BROWS - 1%5D%5Bcol%5D == ' ') %7B%0A      return true;%0A    %7D%0A    return false;%0A  %7D%0A%0A  public int utility() %7B%0A    //TODO Calculate the utility value for the state.%0A    return 0;%0A  %7D%0A%0A  @Override%0A  public String toString() %7B%0A    StringBuilder str = new StringBuilder();%0A    str.append(%22%5Cn%22);%0A    for (int i = ROWS - 1; i %3E= 0; i--) %7B%0A      str.append(%22%7C%22);%0A      for (int j = 0; j %3C COLUMNS; j++) %7B%0A        str.append(this.stateMatrix%5Bi%5D%5Bj%5D);%0A      %7D%0A      str.append(%22%7C%5Cn%22);%0A    %7D%0A    str.append(%22 -------%22);%0A    return str.toString();%0A  %7D%0A%7D%0A

Create GameState.java