public class AtaxxState
extends java.lang.Object
implements java.lang.Cloneable
| Modifier and Type | Field and Description |
|---|---|
static int |
BLUE
A constant integer value representing "blue piece" (in
getPiece(int, int)) and "blue player winner" (in getWinner()). |
static int |
NONE
A constant integer value representing "no piece" (in
getPiece(int, int)) and "no winner" (in getWinner()). |
static int |
RED
A constant integer value representing "red piece" (in
getPiece(int, int)) and "red player winner" (in getWinner()). |
static int |
SIZE
The size of the 7-by-7 square grid.
|
| Constructor and Description |
|---|
AtaxxState()
Initialize board with RED pieces at [0][SIZE-1] and [SIZE-1][0] and BLUE pieces at [0][0] and [SIZE-1][SIZE-1].
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
clone()
Return a deep clone of AtaxxState such that changes to a clone state do not affect the original or vice versa.
|
int |
getCurrentPlayer()
Return the current player (BLUE/RED).
|
int |
getPiece(int row,
int col)
Return the piece (NONE/BLUE/RED) at the given 0-based row and column.
|
int |
getWinner()
Return the winner (BLUE/RED) of the game or NONE if there is no winner.
|
boolean |
grow(int toRow,
int toCol)
Grow into a given 0-based position if and only if it is legal and return whether or not the growth was legal.
|
boolean |
jump(int fromRow,
int fromCol,
int toRow,
int toCol)
Jump between two given 0-based positions if and only if it is legal and return whether or not the jump was legal.
|
public static final int NONE
getPiece(int, int)) and "no winner" (in getWinner()).public static final int BLUE
getPiece(int, int)) and "blue player winner" (in getWinner()).public static final int RED
getPiece(int, int)) and "red player winner" (in getWinner()).public static final int SIZE
public AtaxxState()
public int getPiece(int row,
int col)
row - given rowcol - given columnpublic int getCurrentPlayer()
public int getWinner()
public boolean jump(int fromRow,
int fromCol,
int toRow,
int toCol)
fromRow - row piece is jumped fromfromCol - column piece is jumped fromtoRow - row piece is jumped totoCol - column piece is jumped topublic boolean grow(int toRow,
int toCol)
toRow - row piece is grown totoCol - column piece is grown topublic java.lang.Object clone()
clone in class java.lang.Object