|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectantichess.AIPlayer<M,B>
public class AIPlayer<M extends Move,B extends Board<M>>
A AIPlayer
is a GamePlayer
that uses a
GameAI
to make moves.
Constructor Summary | |
---|---|
AIPlayer(B board,
Player player,
GameAI<M,B> ai)
Creates a new AIPlayer object |
Method Summary | |
---|---|
boolean |
automaticallyTimed()
If a GamePlayer is automatically timed the time is handled by the GameController if it is not automatically timed, the time for a move needs to be handled by the GamePlayer |
void |
gameEnded()
Tell the AI thread to quit |
M |
getMove(GameController controller)
Asks the player for a move, if the player has a move the move is returned, if the player doesn't, null is returned immediately Once this GamePlayer is able to return a valid move it calls notifyControllerHasMove() on the controller. |
Player |
getPlayerType()
|
void |
run()
The thread in the run() method is responsible for actually asking the GameAI to make moves. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AIPlayer(B board, Player player, GameAI<M,B> ai)
board
- player
- Method Detail |
---|
public void run()
The thread in the run() method is responsible for actually
asking the GameAI
to make moves.
The thread spends most of its time sleeping. When
getMove
is called, it sets controller and calls
notify()
to wake the thread. Once the thread wakes
and observes controller
to be non-null, it
computes a move using the GameAI
. When the move
returns, it sets the internal move
variable, calls
notify()
on the Game controller, and then sets the
controller
back to null.
run
in interface Runnable
public M getMove(GameController controller)
GamePlayer
getMove
in interface GamePlayer<M extends Move>
GamePlayer.getMove(GameController)
public void gameEnded()
gameEnded
in interface GamePlayer<M extends Move>
public Player getPlayerType()
getPlayerType
in interface GamePlayer<M extends Move>
public boolean automaticallyTimed()
GamePlayer
automaticallyTimed
in interface GamePlayer<M extends Move>
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |