org.vizzini.game.boardgame.chess.action
Class ChessActionComparator

java.lang.Object
  extended by org.vizzini.game.boardgame.chess.action.ChessActionComparator
All Implemented Interfaces:
Comparator

public class ChessActionComparator
extends Object
implements Comparator

Provides a Comparator to order chess actions. The action order is hopefully useful to the alpha-beta forward search algorithm, with capture moves first.

Since:
v0.3
Version:
v0.3
Author:
Jeffrey M. Thompson

Constructor Summary
ChessActionComparator(IChessEnvironment board)
          Construct this object with the given parameter.
 
Method Summary
 int compare(Object object0, Object object1)
          Return -1, 0, 1 if object0 is less than, equal to, or greater than object1.
protected  int compareActionClass(Class class0, Class class1)
          Sort the action class in this order: PawnPromotionCaptureAction MoveCaptureAction EnPassantCaptureAction PawnPromotionAction MoveAction CastleAction
protected  int compareTokenClass(Class class0, Class class1)
          Sort the token class in this order: IQueen IRook IKnight IBishop IPawn IMace IKing
 void setBoard(IChessEnvironment board)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Constructor Detail

ChessActionComparator

public ChessActionComparator(IChessEnvironment board)
Construct this object with the given parameter.

Parameters:
board - Chess environment. (required)
Since:
v0.3
Method Detail

compare

public int compare(Object object0,
                   Object object1)
Return -1, 0, 1 if object0 is less than, equal to, or greater than object1.

Specified by:
compare in interface Comparator
Since:
v0.3

setBoard

public void setBoard(IChessEnvironment board)
Parameters:
board - The board to set.
Since:
v0.3

compareActionClass

protected int compareActionClass(Class class0,
                                 Class class1)
Sort the action class in this order:
  1. PawnPromotionCaptureAction
  2. MoveCaptureAction
  3. EnPassantCaptureAction
  4. PawnPromotionAction
  5. MoveAction
  6. CastleAction

Parameters:
class0 - First class.
class1 - Second class.
Since:
v0.3

compareTokenClass

protected int compareTokenClass(Class class0,
                                Class class1)
Sort the token class in this order:
  1. IQueen
  2. IRook
  3. IKnight
  4. IBishop
  5. IPawn
  6. IMace
  7. IKing

Parameters:
class0 - First class.
class1 - Second class.
Since:
v0.3


Copyright © 2007 Vizzini.org. All Rights Reserved. 2007.12.25.03.00.02