Class RelativeTerritoryEvaluator

  • All Implemented Interfaces:
    Evaluator

    public class RelativeTerritoryEvaluator
    extends java.lang.Object
    implements Evaluator
    Implements the "relative territory heuristic" for evaluating board states.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static int[][] copy2dArray​(int[][] array)
      Copy a 2-dimensional array because Arrays.copyOf doesn't work with 2d arrays.
      float evaluate​(Board board, int playerId)
      board value from perspective of player with given id.
      int getBoardValue​(int[][] squares, int playerId)
      Calculate the value of a board based on relative territory heuristic.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RelativeTerritoryEvaluator

        public RelativeTerritoryEvaluator()
    • Method Detail

      • evaluate

        public float evaluate​(Board board,
                              int playerId)
        board value from perspective of player with given id.
        Specified by:
        evaluate in interface Evaluator
        Parameters:
        board - the position to be evaluated
        playerId - the player that moves next
        Returns:
        negative values for unfavorable boards; positive for favorable ones
      • getBoardValue

        public int getBoardValue​(int[][] squares,
                                 int playerId)
        Calculate the value of a board based on relative territory heuristic.
        Parameters:
        squares - the 'real' playboard
        Returns:
        value of board = number of squares i reach faster - number of squares my enemy reaches faster
      • copy2dArray

        public static int[][] copy2dArray​(int[][] array)
        Copy a 2-dimensional array because Arrays.copyOf doesn't work with 2d arrays.
        Parameters:
        array - array to be copied
        Returns:
        copied array