org.moyoman.helper.board.rules
Class RulesHelper

java.lang.Object
  |
  +--org.moyoman.helper.Helper
        |
        +--org.moyoman.helper.board.rules.RulesHelper
All Implemented Interfaces:
Cloneable, Component, Serializable
Direct Known Subclasses:
AGARules, RulesImpl

public abstract class RulesHelper
extends Helper

Classes which extend this one help the Board module. They are used in determining legal and illegal moves for various rule sets.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.moyoman.helper.Helper
 
Constructor Summary
RulesHelper(GameId gid, Mode mode, HelperName name, Component parent)
          Create the RulesHelper object.
 
Method Summary
abstract  boolean doCountPointsInSeki()
          Determine if territory in a seki is counted.
abstract  Set findPrisoners(Board board)
          Find the prisoners that should be removed.
abstract  boolean freePlacementOfHandicapStones()
          Determine if handicap stones must be placed in a set pattern.
abstract  Stone getKo()
          Get the move that would be illegal due to immediately retaking a ko.
abstract  float getKomi()
          Get the komi.
abstract  short getLegalityStatus(NumberedStone ns, Board board)
          Determine the status of the given move.
abstract  Rules getRules()
          Determine the type of rules for this game.
abstract  Stone[] getSuicide()
          Get the moves which would be illegal due to suicide on the next move.
abstract  Stone[] getSuperKo()
          Get the moves that would be illegal because of recreating a whole board position.
abstract  boolean isBentFourDeadByRule()
          Determine if the bent four group is dead by rule, or must be played out.
abstract  boolean isLegalMove(NumberedStone ns, Board board)
          Determine if the given move is legal.
abstract  boolean isSuicideAllowed()
          Determine if suicide is allowed.
abstract  boolean isTerritoryScoring()
          Determine if territory (Japanese) or area (Chinese) scoring is used.
abstract  void makeMove(Board board)
          Update the RulesHelper with the latest move.
abstract  boolean mustWhiteMoveLast()
          Determine if white must move last.
abstract  short numberOfPassesToEndGame()
          Determine the number of consecutive passes that ends the game.
abstract  short superKoRule()
          Determine the type of super ko rule in effect.
 
Methods inherited from class org.moyoman.helper.Helper
checkTime, clone, create, createHelper, debug, error, error, fatal, fatal, getAllHelpers, getDebugInformation, getDebugTypes, getHelper, getHelperName, getId, getMode, getModule, getParent, getRequiredModuleList, getScheduler, information, setTime, warning, warning
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RulesHelper

public RulesHelper(GameId gid,
                   Mode mode,
                   HelperName name,
                   Component parent)
            throws InternalErrorException
Create the RulesHelper object.

Parameters:
gid - The game id.
mode - The mode of the game.
name - The name of the specific helper.
parent - The Board object.
Throws:
InternalErrorException - Thrown if the operation fails for any reason.
Method Detail

doCountPointsInSeki

public abstract boolean doCountPointsInSeki()
Determine if territory in a seki is counted.

Returns:
true if territory in a seki is counted, or false.

freePlacementOfHandicapStones

public abstract boolean freePlacementOfHandicapStones()
Determine if handicap stones must be placed in a set pattern.

Returns:
false if the handicap stones must be placed in a set pattern, or true.

getKomi

public abstract float getKomi()
Get the komi.

Returns:
A float which is the komi.

isBentFourDeadByRule

public abstract boolean isBentFourDeadByRule()
Determine if the bent four group is dead by rule, or must be played out.

Returns:
true if the bent four group is dead by rule, or false.

isSuicideAllowed

public abstract boolean isSuicideAllowed()
Determine if suicide is allowed.

Returns:
true if suicide is allowed, or false.

isTerritoryScoring

public abstract boolean isTerritoryScoring()
Determine if territory (Japanese) or area (Chinese) scoring is used.

Returns:
true if territory scoring is used, or false.

mustWhiteMoveLast

public abstract boolean mustWhiteMoveLast()
Determine if white must move last. Each time that a player passes, he must give his opponent a prisoner. If this method is true, then if black makes a pass that would end the game, white must still pass after that.

Returns:
true if white must move last, or false.

numberOfPassesToEndGame

public abstract short numberOfPassesToEndGame()
Determine the number of consecutive passes that ends the game.

Returns:
A short that is the number of consecutive passes that ends the game.

superKoRule

public abstract short superKoRule()
Determine the type of super ko rule in effect.

Returns:
A short which is one of:
  1. Board.ALLOWED
  2. Board.DRAW
  3. Board.FORBIDDEN

getSuicide

public abstract Stone[] getSuicide()
Get the moves which would be illegal due to suicide on the next move. Note that if isSuicideAllowed() is true, then the array returned by this method will always be of size 0.

Returns:
An array of Stone objects.

getKo

public abstract Stone getKo()
Get the move that would be illegal due to immediately retaking a ko.

Returns:
The stone which is the illegal move, or null if there is no ko.

getSuperKo

public abstract Stone[] getSuperKo()
Get the moves that would be illegal because of recreating a whole board position. If superKoRule() would return Board.ALLOWED, then this method will always return an array of size 0.

Returns:
An array of Stone objects.

isLegalMove

public abstract boolean isLegalMove(NumberedStone ns,
                                    Board board)
Determine if the given move is legal.

Parameters:
ns - The move being tested.
board - The Board object with the current board position.
Returns:
true if the move is legal, or false.

getLegalityStatus

public abstract short getLegalityStatus(NumberedStone ns,
                                        Board board)
Determine the status of the given move. If the move is illegal, then it returns the reason why it is illegal.

Parameters:
ns - The move being tested.
board - The Board object with the current board position.
Returns:
A short which is one of the following possibilities:
  1. Board.LEGAL
  2. Board.KO
  3. Board.SUICIDE
  4. Board.SUPERKO
  5. Board.FILLED
  6. Board.WRONG_COLOR

makeMove

public abstract void makeMove(Board board)
Update the RulesHelper with the latest move.

Parameters:
board - The Board object which contains the state of the board.

findPrisoners

public abstract Set findPrisoners(Board board)
Find the prisoners that should be removed.

Parameters:
board - The Board object with the current state of the board with prisoners still present.
Returns:
A Set which contains Stone objects which are the prisoners to be removed.

getRules

public abstract Rules getRules()
Determine the type of rules for this game.

Returns:
A Rules object.