java.lang.Objectedu.gwu.champAlg.TicBoard
public class TicBoard
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 |
---|
public char[][] board
Constructor Detail |
---|
public TicBoard(int N, int M)
Method Detail |
---|
public TicBoard copy()
TicBoard
valuepublic java.lang.String testAndMove(TicMove move, boolean isNoughts)
public boolean isFull()
boolean
valuepublic boolean isGameOver()
boolean
valuepublic java.util.ArrayList<TicMove> getLegalMoves()
ArrayList
valuepublic boolean valid(int x, int y)
public double value()
public boolean testGameOver(boolean isNoughts)
public java.lang.String toString()
toString
in class java.lang.Object
String
valuepublic java.lang.String toString(java.lang.String blanks)