public class AtaxxGame
extends java.lang.Object
| Constructor and Description |
|---|
AtaxxGame() |
| Modifier and Type | Method and Description |
|---|---|
static void |
main(java.lang.String[] args)
Provide a text-based interface for playing the game of Ataxx making use of the
AtaxxState class. |
static java.lang.String |
stateToString(AtaxxState state)
Given a
AtaxxState object, return the String that represents the current game state. |
public static java.lang.String stateToString(AtaxxState state)
AtaxxState object, return the String that represents the current game state.
The RED, empty (i.e. NONE), and BLUE positions are
represented by 'O', '-', and 'X', respectively. Rows are labeled on the left and right with row numbers descending from
7 to 1. (Note that this is one greater than the row number of the internal representation. Columns are labeled
on the top and bottom from left to right with column letters 'a' through 'g'. Columns and labels are space-separated.
Below the board, a single line indicate the player to play or the player that has won with one of the following messages:
String corresponding to the initial game state would look like:
a b c d e f g 7 O - - - - - X 7 6 - - - - - - - 6 5 - - - - - - - 5 4 - - - - - - - 4 3 - - - - - - - 3 2 - - - - - - - 2 1 X - - - - - O 1 a b c d e f g O to play.
state - - the game state to represent as a StringString representation of the game statepublic static void main(java.lang.String[] args)
AtaxxState class.
Initially, print four lines as follows:
ATAXX A position is indicated by a letter and number as in Chess (e.g. "b4"). For a growth move, please enter the position into which you will grow. For a jump move, please enter the from and to positions separated by a space.Then, for each turn of the game, print the board using
stateToString to generate the board String.
Print a blank line, prompt the user for a move with "Move? ", and read the user input.
If the move has an illegal input format, print the message "Illegal move format.".
If the move has a legal input format but is an illegal move, print "Illegal move.".
Otherwise, the move is taken. (Note: The return value of AtaxxState class makeMove method provides illegal move feedback.)
Once the game ends, the board is printed one last time.args - (unused)