sandy.game.core
Class Player
java.lang.Object
|
+--sandy.game.core.Player
- Direct Known Subclasses:
- ComputerPlayer, HumanPlayer
- public abstract class Player
- extends java.lang.Object
This is the base class for players in the game. The players in the game are queried
by the game engine for their next moves till the game is over. Now, a player can be
either Human or Computer. A human player generally interacts with a user interface to
input his moves and the computer relies on a decision engine to generate its next
best move. To implement this concept generically, this class implements a
publisher-subscriber model to return the next move. In case a move is not set the call
to getMove waits till a move is set.
|
Method Summary |
protected void |
generateNextMove()
This function should be overridden by sub classes who want to do
the processing in the same thread.. |
Move |
getMove()
Gets the next move for this player. |
void |
setNextMove(Move move)
Set the next best move for this player. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
gameBoard
protected GameBoard gameBoard
perspective
protected int perspective
Player
protected Player(GameBoard gameBoard,
int perspective)
getMove
public Move getMove()
- Gets the next move for this player.
setNextMove
public void setNextMove(Move move)
- Set the next best move for this player. This function is generally called either
by the ui (In case of a human player) and by the decision engine in case of a
computer player.
generateNextMove
protected void generateNextMove()
- This function should be overridden by sub classes who want to do
the processing in the same thread.. like the computer player. This
method should call the setNextMove to set the processed move.