org.moyoman.util
Class MoveDescriptor

java.lang.Object
  |
  +--org.moyoman.util.MoveDescriptor
All Implemented Interfaces:
Cloneable, Serializable

public class MoveDescriptor
extends Object
implements Cloneable, Serializable

This class contains information about a move. This information includes the move itself, whether a ko was just captured, whether any prisoners were just captured, and any points where the next move would be illegal.

See Also:
Serialized Form

Field Summary
private  boolean eogFlag
          The end of the game flag.
private  Stone ko
          The stone which playing at would illegal retake the ko.
private  String message
          An explanation of the move.
private  Move move
          The move being described.
private  Stone[] prisoners
          Any prisoners captured by this move.
private  Stone[] suicide
          Any moves which would be illegal because of suicide on the next move.
private  Stone[] superko
          Any moves which would recreate the whole board position on the next move.
 
Constructor Summary
MoveDescriptor(Move m)
          Create a new MoveDescriptor object.
MoveDescriptor(Move m, String msg)
          Create a new MoveDescriptor object.
 
Method Summary
 void addKo(Stone stone)
          Specify a stone which cannot be played because it would illegally retake the ko.
 void addPrisoner(Stone stone)
          Add a stone to the list of prisoners which were captured by this move.
 void addPrisoners(Stone[] stones)
          Add stones to the list of prisoners which were captured by this move.
 void addSuicideMove(Stone stone)
          Add a move to the list of those moves that are not legal because of suicide after this move.
 void addSuicideMoves(Stone[] stones)
          Add moves to the list of those moves that are not legal because of suicide after this move.
 void addSuperKoMove(Stone stone)
          Add a move to the list of those moves that are not legal because they illegally recreate the whole board position after this move.
 void addSuperKoMoves(Stone[] stones)
          Add moves to the list of those moves that are not legal because they illegally recreate the whole board position after this move.
 Object clone()
          Clone this object.
 Stone[] getIllegalMoves()
          Return an array of all illegal moves.
 Stone getKo()
          Return the stone which may not be played on the next move because it is illegally retaking the ko.
 String getMessage()
          Get the description of the move.
 Move getMove()
          Get the move object.
 Stone[] getPrisoners()
          Return an array of prisoners captured by this move.
 Stone[] getSuicideMoves()
          Get all of the moves which are illegal because of suicide.
 Stone[] getSuperKoMoves()
          Get all of the moves which are illegal because of recreating the whole board position.
 int hashCode()
          Get a hash code for this object.
 boolean isEndOfGame()
          Determine whether the move has caused the end of the game.
 boolean isKo()
          Return whether a ko was just captured.
 void setEndOfGame(boolean flag)
          Set the end of game flag.
 void setMessage(String msg)
          Set the description of the move.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

move

private Move move
The move being described.


ko

private Stone ko
The stone which playing at would illegal retake the ko.


prisoners

private Stone[] prisoners
Any prisoners captured by this move.


suicide

private Stone[] suicide
Any moves which would be illegal because of suicide on the next move.


superko

private Stone[] superko
Any moves which would recreate the whole board position on the next move.


message

private String message
An explanation of the move.


eogFlag

private boolean eogFlag
The end of the game flag.

Constructor Detail

MoveDescriptor

public MoveDescriptor(Move m)
Create a new MoveDescriptor object.

Parameters:
m - The move being described.

MoveDescriptor

public MoveDescriptor(Move m,
                      String msg)
Create a new MoveDescriptor object.

Parameters:
m - The move being described.
msg - A description of the move.
Method Detail

setMessage

public void setMessage(String msg)
Set the description of the move.

Parameters:
msg - The description.

getMessage

public String getMessage()
Get the description of the move.

Returns:
A String which is the description of the move.

addKo

public void addKo(Stone stone)
Specify a stone which cannot be played because it would illegally retake the ko.

Parameters:
stone - The position which cannot be played without making a ko threat first.

addPrisoner

public void addPrisoner(Stone stone)
Add a stone to the list of prisoners which were captured by this move.

Parameters:
stone - The stone that was captured.

addPrisoners

public void addPrisoners(Stone[] stones)
Add stones to the list of prisoners which were captured by this move.

Parameters:
stones - The stone that were captured.

addSuicideMove

public void addSuicideMove(Stone stone)
Add a move to the list of those moves that are not legal because of suicide after this move.


addSuperKoMove

public void addSuperKoMove(Stone stone)
Add a move to the list of those moves that are not legal because they illegally recreate the whole board position after this move.


addSuicideMoves

public void addSuicideMoves(Stone[] stones)
Add moves to the list of those moves that are not legal because of suicide after this move.


addSuperKoMoves

public void addSuperKoMoves(Stone[] stones)
Add moves to the list of those moves that are not legal because they illegally recreate the whole board position after this move.


getKo

public Stone getKo()
Return the stone which may not be played on the next move because it is illegally retaking the ko. Return null if there is no ko.

Returns:
The illegal point.

isEndOfGame

public boolean isEndOfGame()
Determine whether the move has caused the end of the game.

Returns:
true if the end of the game, or false.

setEndOfGame

public void setEndOfGame(boolean flag)
Set the end of game flag.

Parameters:
flag - true if the game is over, or false.

getSuicideMoves

public Stone[] getSuicideMoves()
Get all of the moves which are illegal because of suicide.

Returns:
An array of Stone objects.

getSuperKoMoves

public Stone[] getSuperKoMoves()
Get all of the moves which are illegal because of recreating the whole board position.

Returns:
An array of Stone objects.

getIllegalMoves

public Stone[] getIllegalMoves()
Return an array of all illegal moves. This includes moves that are suicide, illegally retaking the ko, or recreating a full board position (superko).

Returns:
An array of Stone objects.

getMove

public Move getMove()
Get the move object.

Returns:
The Move object.

getPrisoners

public Stone[] getPrisoners()
Return an array of prisoners captured by this move. If there are no prisoners, an array of length 0 is returned.

Returns:
The prisoners captured by this move.

isKo

public boolean isKo()
Return whether a ko was just captured.

Returns:
true if a ko was just captured, or false.

hashCode

public int hashCode()
Get a hash code for this object. The reason that this method is defined here is to make it explicit that other classes are dependent on each object having a different hash code, specifically, MoveDescriptorForest.

Overrides:
hashCode in class Object
Returns:
An int which is the hashcode.

clone

public Object clone()
Clone this object.

Overrides:
clone in class Object
Returns:
A MoveDescriptor object which is a clone of this one.