Class MoveComparator

  • All Implemented Interfaces:
    java.util.Comparator<Move>

    public class MoveComparator
    extends java.lang.Object
    implements java.util.Comparator<Move>
    Sort moves according to a strategy.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected IBoard board
      The board (required for checking which piece is in a given position).
      protected java.lang.String strategy
      The strategy.
      static java.lang.String STRATEGY_ALTER_LONG
      The strategy preferring jump moves of different colors.
      static java.lang.String STRATEGY_LONG
      The strategy preferring jump moves, but ignoring colors.
      static java.lang.String STRATEGY_NONE
      No strategy: try moves in order of appearance.
      static java.lang.String STRATEGY_SAME_LONG
      The strategy preferring jump moves of same color.
    • Constructor Summary

      Constructors 
      Constructor Description
      MoveComparator​(IBoard board, java.lang.String strategy)
      Create a move comparator.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compare​(Move move1, Move move2)
      Compare two moves.
      • 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, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
    • Field Detail

      • STRATEGY_NONE

        public static final java.lang.String STRATEGY_NONE
        No strategy: try moves in order of appearance.
        See Also:
        Constant Field Values
      • STRATEGY_LONG

        public static final java.lang.String STRATEGY_LONG
        The strategy preferring jump moves, but ignoring colors.
        See Also:
        Constant Field Values
      • STRATEGY_SAME_LONG

        public static final java.lang.String STRATEGY_SAME_LONG
        The strategy preferring jump moves of same color.
        See Also:
        Constant Field Values
      • STRATEGY_ALTER_LONG

        public static final java.lang.String STRATEGY_ALTER_LONG
        The strategy preferring jump moves of different colors.
        See Also:
        Constant Field Values
      • board

        protected IBoard board
        The board (required for checking which piece is in a given position).
      • strategy

        protected java.lang.String strategy
        The strategy.
    • Constructor Detail

      • MoveComparator

        public MoveComparator​(IBoard board,
                              java.lang.String strategy)
        Create a move comparator.
    • Method Detail

      • compare

        public int compare​(Move move1,
                           Move move2)
        Compare two moves.
        Specified by:
        compare in interface java.util.Comparator<Move>
        Returns:
        A negative number when the first move should come before the second.