Class LineEvaluator


  • public class LineEvaluator
    extends java.lang.Object
    Test that we can correctly evaluate a run of symbols on the board.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected Patterns patterns_  
    • Constructor Summary

      Constructors 
      Constructor Description
      LineEvaluator​(Patterns patterns, com.barrybecker4.optimization.parameter.ParameterArray weights)
      Constructor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int evaluate​(java.lang.CharSequence line, boolean player1Perspective, int pos, int minpos, int maxpos)
      Evaluate a line (vertical, horizontal, or diagonal) from the specified player point of view.
      int getMinInterestingLength()  
      protected java.lang.CharSequence getPattern​(java.lang.CharSequence line, char opponentSymb, int pos, int minpos, int maxpos)  
      protected int getWeightIndex​(java.lang.CharSequence line, char opponentSymb, int pos, int minpos, int maxpos)
      In general, we march from the position pos in the middle towards the ends of the string.
      • Methods inherited from class java.lang.Object

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

      • patterns_

        protected Patterns patterns_
    • Constructor Detail

      • LineEvaluator

        public LineEvaluator​(Patterns patterns,
                             com.barrybecker4.optimization.parameter.ParameterArray weights)
        Constructor
        Parameters:
        patterns - patterns to lookout for.
        weights - weights amount to weight different patterns found in line.
    • Method Detail

      • getMinInterestingLength

        public int getMinInterestingLength()
      • evaluate

        public int evaluate​(java.lang.CharSequence line,
                            boolean player1Perspective,
                            int pos,
                            int minpos,
                            int maxpos)
        Evaluate a line (vertical, horizontal, or diagonal) from the specified player point of view.
        Parameters:
        line - the line to evaluate
        player1Perspective - if true, then the first player just moved, else the second player. Note: this value does not guarantee anything about the symbol at position pos. It can be either players symbol or unoccupied.
        pos - the position that was just played (symbol).
        minpos - starting pattern index in line (usually 0).
        maxpos - last pattern index position in line (usually one less than the line magnitude).
        Returns:
        the worth of a (vertical, horizontal, left diagonal, or right diagonal) line.
      • getWeightIndex

        protected int getWeightIndex​(java.lang.CharSequence line,
                                     char opponentSymb,
                                     int pos,
                                     int minpos,
                                     int maxpos)
        In general, we march from the position pos in the middle towards the ends of the string. Marching stops when we encounter one of the following conditions: - 2 blanks in a row (@@ we may want to allow this) - an opponent's blocking piece - the end of a line.
        Parameters:
        minpos - first symbol in the sting to evaluate
        maxpos - last symbol in the sting to evaluate
        Returns:
        the index to use for getting the weight based on the pattern formed by this line.
      • getPattern

        protected java.lang.CharSequence getPattern​(java.lang.CharSequence line,
                                                    char opponentSymb,
                                                    int pos,
                                                    int minpos,
                                                    int maxpos)