All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class taxman.Board

java.lang.Object
   |
   +----taxman.Board

public class Board
extends Object
Class Board The Board represents game state. It holds the - list of available numbers - stack of moves made - current turn It can - Make a move based on a number choice - Make a move based on an index into its list of available numbers - Add a number into its list of available numbers - Undo the last move made - Give an evaluation of current game state (who's winning) - Print out the current game state including + board status + scores + previous moves


Variable Index

 o CPU
Identifies cpu turn
 o HUMAN
Identifies human turn

Constructor Index

 o Board()
Default human starts
 o Board(int)
Constructor only sets the initial player

Method Index

 o addNumber(int)
This function adds a number to the vector of available moves.
 o addNumber(TaxNumber)
This function adds a number to the vector of available moves.
 o displayState()
Displays current state of board, score, and other things.
 o endBoardFill()
Ends the board filling phase, now a move can be made.
 o evaluate()
The evaluation function for the board.
 o getAvailableMoves()
Retrieves a list of numerically ordered numbers that are available for choosing.
 o getCPUScore()
Returns the current CPU score
 o getCurrentTurn()
Returns the the player who has the current move.
 o getHumanScore()
Returns the current Human score
 o getLastMove()
Returns the last move made.
 o getMoveAtIndex(int)
Returns the move stored at the index i (the way this board stores moves could be different from other boards, but the effect is the same)
 o getNextIndexedMove(int)
Gets the next available move after the given index, n.
 o getNumberOfAvailableMoves()
Returns the number of available moves (just the number of choices the the player has at this time)
 o getWinner()
Returns the winner ID (if the game ended at this state
 o main(String[])
Test function.
 o makeIndexedMove(int)
Makes ith possible move at this level.
 o makeMove(int)
Makes the given move (chooses the number and gives the tax numbers to the opponent).
 o makeMove(TaxNumber)
Makes the given move (chooses the number and gives the tax numbers to the opponent).
 o removeNumber(TaxNumber)
Removes the given number from the list of available moves.
 o undoLastMove()
Undoes the last move, putting the board in the same state it was in before last move.

Variables

 o HUMAN
 public static final int HUMAN
Identifies human turn

 o CPU
 public static final int CPU
Identifies cpu turn

Constructors

 o Board
 public Board()
Default human starts

 o Board
 public Board(int Player)
Constructor only sets the initial player

Parameters:
Player - Id for the player who will start

Methods

 o addNumber
 public final synchronized void addNumber(int n)
This function adds a number to the vector of available moves. The ordering is by decreasing factor numbers. (overloaded for ints) Therefore, 13, with 2 factors, comes after 4 with 3 factors

Parameters:
n - The number to add to the available move list
 o addNumber
 public final synchronized void addNumber(TaxNumber n)
This function adds a number to the vector of available moves. The ordering is by decreasing factor numbers. Therefore, 13, with 2 factors, comes after 4 with 3 factors

Parameters:
n - The number to add to the available move list
 o endBoardFill
 public final synchronized void endBoardFill()
Ends the board filling phase, now a move can be made. If a move is made before calling this function, an exception will likely occure. After this function is called, no more numbers can be added to the game board. You can make and and undo moves, that's all.

 o removeNumber
 public final synchronized TaxNumber removeNumber(TaxNumber n)
Removes the given number from the list of available moves.

Parameters:
n - The number to remove from the list of available moves
Returns:
If n exists as a valid move, it is removed from the vector of available moves and returned. Otherwise, null is returned.
 o makeMove
 public final synchronized boolean makeMove(int n)
Makes the given move (chooses the number and gives the tax numbers to the opponent). The move and its available factors are removed from the list of available numbers.

Parameters:
n - The number to choose on making the move
Returns:
true if the number is a valid move. false otherwise.
 o makeMove
 public final synchronized boolean makeMove(TaxNumber n)
Makes the given move (chooses the number and gives the tax numbers to the opponent). The move and its available factors are removed from the list of available numbers.

Parameters:
n - The number to choose on making the move
Returns:
true if the number is a valid move. false otherwise.
 o getNextIndexedMove
 public final synchronized int getNextIndexedMove(int n)
Gets the next available move after the given index, n.

Parameters:
n - The index after which to find the available move. i.e. to find the first move n = -1.
Returns:
The index of the next move after n. If this index is used in a call to makeIndexedMove() the system will garrantee a valid move (assuming no other changes).
 o makeIndexedMove
 public final synchronized boolean makeIndexedMove(int index)
Makes ith possible move at this level. The total of moves available at this level are given by getNumberOfAvaialbleMoves()

Parameters:
index - Index of move that should be tried
Returns:
true if the indexed move is value (should be). false otherwise.
 o undoLastMove
 public final synchronized boolean undoLastMove()
Undoes the last move, putting the board in the same state it was in before last move.

Returns:
true if the undo was successful, false otherwise.
 o evaluate
 public final synchronized int evaluate()
The evaluation function for the board. It is very simple. It's evaluation turns out to just be the difference in scores at this time. The bigger the difference, the better the state.

Returns:
An integer representing the quality of this move
 o getMoveAtIndex
 public final Object getMoveAtIndex(int i)
Returns the move stored at the index i (the way this board stores moves could be different from other boards, but the effect is the same)

Returns:
The move (as an object) at the given index
 o getNumberOfAvailableMoves
 public final int getNumberOfAvailableMoves()
Returns the number of available moves (just the number of choices the the player has at this time)

Returns:
The number of moves available at the current state
 o getLastMove
 public final Move getLastMove()
Returns the last move made.

Returns:
the last move made (from the stack)
 o getCurrentTurn
 public final int getCurrentTurn()
Returns the the player who has the current move.

Returns:
The value Board.HUMAN if it is the human's turn The value Board.CPU if it is the cpu's turn
 o getWinner
 public final int getWinner()
Returns the winner ID (if the game ended at this state

Returns:
The winner's id
 o getCPUScore
 public final int getCPUScore()
Returns the current CPU score

Returns:
The current CPU score
 o getHumanScore
 public final int getHumanScore()
Returns the current Human score

Returns:
the current Human score
 o getAvailableMoves
 public final synchronized int[] getAvailableMoves()
Retrieves a list of numerically ordered numbers that are available for choosing.

Returns:
An array of numbers sorted numerically indicating the numbers that are available for choosing.
 o displayState
 public final void displayState()
Displays current state of board, score, and other things.

 o main
 public static void main(String args[])
Test function.


All Packages  Class Hierarchy  This Package  Previous  Next  Index