|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.moyoman.comm.client.Player | +--org.moyoman.comm.client.NonvalidatedPlayer
Any class which extends this class can be used as one of the players in a game of Go. Players which derive from this class do not perform error checking on the moves which they make. This class handles that task so that the derived class does not have to. Some examples of these classes are a human user with the mouse and a player communicating through a socket using the GTP protocol.
Field Summary | |
private Stone |
ko
This is the move which would result in illegally retaking the ko, or null. |
private MoveValidator |
mv
This object is used to validate the moves. |
private Stone[] |
suicide
Any of the Stone objects in this array would be an illegal move because of suicide. |
private Stone[] |
superko
Any of the Stone objects in this array would be an illegal move because of superko. |
Fields inherited from class org.moyoman.comm.client.Player |
color, handicap |
Constructor Summary | |
|
NonvalidatedPlayer(Color c,
Handicap h)
Create the NonvalidatedPlayer object. |
protected |
NonvalidatedPlayer(Color c,
Handicap h,
String id)
|
Method Summary | |
void |
derivedMakeMove(MoveDescriptor md)
Make a move, and validate it. |
MoveDescriptor |
derivedRequestMove()
Request a move, and validate it. |
GameRecord |
getGameRecord()
Get the game record for this player. |
String |
getId()
Return the id for the move validator. |
Stone |
getKo()
Return the stone which would be an illegal retaking of the ko. |
short |
getMoveNumber()
Get the move number. |
protected abstract Move |
getRequestedMove()
The derived class must override this method to get a move from the player. |
boolean |
isSelfInitializingUser()
Return whether the player initializes itself on startup. |
boolean |
isValidatedUser()
Returns false, since all derived classes of this one do not validate their own moves. |
protected abstract void |
makeValidatedMove(MoveDescriptor md)
The derived class must override this method to make a move. |
private void |
setKo(Stone ko)
This method sets the move that is illegal because it immediately retakes the ko. |
private void |
setSuicideMoves(Stone[] moves)
This method sets the moves that are illegal because of suicide. |
private void |
setSuperKoMoves(Stone[] moves)
This method sets the moves that are illegal because of superko. |
void |
validateMove(Stone move)
This method exits normally if the move is legal, or throws an exception otherwise. |
Methods inherited from class org.moyoman.comm.client.Player |
getColor, getHandicap, getIdentifyingInfo, makeMove, makeMoveNoEvents, registerEndOfGameMoveListener, registerMakeMoveListener, registerRequestMoveListener, requestMove, unregisterEndOfGameListeners, unregisterMakeMoveListeners, unregisterRequestMoveListeners |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private MoveValidator mv
private Stone ko
private Stone[] suicide
private Stone[] superko
Constructor Detail |
public NonvalidatedPlayer(Color c, Handicap h) throws InternalErrorException
c
- The color of the player.h
- The handicap of the game.
InternalErrorException
- Thrown if the operation fails for any reason.protected NonvalidatedPlayer(Color c, Handicap h, String id) throws InternalErrorException
Method Detail |
public final void derivedMakeMove(MoveDescriptor md) throws IllegalMoveException, InternalErrorException
derivedMakeMove
in class Player
md
- The MoveDescriptor which describes the move to make.
IllegalMoveException
- - Thrown if the move to be made is illegal.
InternalErrorException
- Thrown if the operation fails for any reason.protected abstract void makeValidatedMove(MoveDescriptor md) throws IllegalMoveException, InternalErrorException
md
- The move to be made.
IllegalMoveException
- - Thrown if the move to be made is illegal.
InternalErrorException
- Thrown if the operation fails for any reason.public final MoveDescriptor derivedRequestMove() throws IllegalMoveException, InternalErrorException
derivedRequestMove
in class Player
IllegalMoveException
- - Thrown if the move to be made is illegal.
InternalErrorException
- Thrown if the operation fails for any reason.public short getMoveNumber() throws InternalErrorException
getMoveNumber
in class Player
InternalErrorException
- Thrown if the operation fails for any reason.public GameRecord getGameRecord() throws InternalErrorException
getGameRecord
in class Player
InternalErrorException
- Thrown if the operation fails for any reason.protected abstract Move getRequestedMove()
public boolean isValidatedUser()
isValidatedUser
in class Player
private void setKo(Stone ko)
ko
- The stone which is an illegal move without making a ko threat.
This parameter may be null if there is no ko.private void setSuicideMoves(Stone[] moves)
moves
- An array of Stone objects.private void setSuperKoMoves(Stone[] moves)
moves
- An array of Stone objects.public Stone getKo()
public void validateMove(Stone move) throws IllegalMoveException
move
- The move in question.
A
- derived class of IllegalMoveException corresponding to the reason why
the move is illegal.
IllegalMoveException
public boolean isSelfInitializingUser()
Player
isSelfInitializingUser
in class Player
public String getId()
getId
in class Player
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |