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
-
CPU
- Identifies cpu turn
-
HUMAN
- Identifies human turn
-
Board()
- Default human starts
-
Board(int)
- Constructor only sets the initial player
-
addNumber(int)
- This function adds a number to the vector of available moves.
-
addNumber(TaxNumber)
- This function adds a number to the vector of available moves.
-
displayState()
- Displays current state of board, score, and other things.
-
endBoardFill()
- Ends the board filling phase, now a move can be made.
-
evaluate()
- The evaluation function for the board.
-
getAvailableMoves()
- Retrieves a list of numerically ordered numbers that are available for choosing.
-
getCPUScore()
- Returns the current CPU score
-
getCurrentTurn()
- Returns the the player who has the current move.
-
getHumanScore()
- Returns the current Human score
-
getLastMove()
- Returns the last move made.
-
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)
-
getNextIndexedMove(int)
- Gets the next available move after the given index, n.
-
getNumberOfAvailableMoves()
- Returns the number of available moves (just the number of choices the
the player has at this time)
-
getWinner()
- Returns the winner ID (if the game ended at this state
-
main(String[])
- Test function.
-
makeIndexedMove(int)
- Makes ith possible move at this level.
-
makeMove(int)
- Makes the given move (chooses the number and gives the
tax numbers to the opponent).
-
makeMove(TaxNumber)
- Makes the given move (chooses the number and gives the
tax numbers to the opponent).
-
removeNumber(TaxNumber)
- Removes the given number from the list of available moves.
-
undoLastMove()
- Undoes the last move, putting the board in the same state
it was in before last move.
HUMAN
public static final int HUMAN
- Identifies human turn
CPU
public static final int CPU
- Identifies cpu turn
Board
public Board()
- Default human starts
Board
public Board(int Player)
- Constructor only sets the initial player
- Parameters:
- Player - Id for the player who will start
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
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
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.
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.
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.
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.
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).
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.
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.
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
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
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
getLastMove
public final Move getLastMove()
- Returns the last move made.
- Returns:
- the last move made (from the stack)
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
getWinner
public final int getWinner()
- Returns the winner ID (if the game ended at this state
- Returns:
- The winner's id
getCPUScore
public final int getCPUScore()
- Returns the current CPU score
- Returns:
- The current CPU score
getHumanScore
public final int getHumanScore()
- Returns the current Human score
- Returns:
- the current Human score
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.
displayState
public final void displayState()
- Displays current state of board, score, and other things.
main
public static void main(String args[])
- Test function.
All Packages Class Hierarchy This Package Previous Next Index