edu.gwu.champAlg
Class TicBoard

java.lang.Object
  extended by edu.gwu.champAlg.TicBoard

public class TicBoard
extends java.lang.Object

This class handles all the moves related to the board. There are a couple of useful methods you can call, but most importantly, you can view the board, which is of type char[][]. Nought uses 'O' (capital) and Cross uses 'X' (capital). Unused cells use ' ' (blank).


Field Summary
 char[][] board
          The state of the board.
 
Constructor Summary
TicBoard(int N, int M)
           
 
Method Summary
 TicBoard copy()
          Makes a complete copy of the board.
 java.util.ArrayList<TicMove> getLegalMoves()
          Return a list of legal (empty) squares.
 boolean isFull()
          Call this to see if the board is completely occupied.
 boolean isGameOver()
          Call this to see if either side has won.
 java.lang.String testAndMove(TicMove move, boolean isNoughts)
           
 boolean testGameOver(boolean isNoughts)
           
 java.lang.String toString()
          Prints a current snapshot, useful in debugging.
 java.lang.String toString(java.lang.String blanks)
           
 boolean valid(int x, int y)
           
 double value()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

board

public char[][] board
The state of the board.

Constructor Detail

TicBoard

public TicBoard(int N,
                int M)
Method Detail

copy

public TicBoard copy()
Makes a complete copy of the board. This is useful in exploring the game tree.

Returns:
a TicBoard value

testAndMove

public java.lang.String testAndMove(TicMove move,
                                    boolean isNoughts)

isFull

public boolean isFull()
Call this to see if the board is completely occupied. Useful in determining whether a leaf has been reached in a game tree.

Returns:
a boolean value

isGameOver

public boolean isGameOver()
Call this to see if either side has won.

Returns:
a boolean value

getLegalMoves

public java.util.ArrayList<TicMove> getLegalMoves()
Return a list of legal (empty) squares.

Returns:
an ArrayList value

valid

public boolean valid(int x,
                     int y)

value

public double value()

testGameOver

public boolean testGameOver(boolean isNoughts)

toString

public java.lang.String toString()
Prints a current snapshot, useful in debugging.

Overrides:
toString in class java.lang.Object
Returns:
a String value

toString

public java.lang.String toString(java.lang.String blanks)