Class Line


  • public class Line
    extends java.lang.Object
    Represents a run of symbols to be evaluated on the board. All the symbols in the line should be of the same side.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.StringBuilder line
      contains the symbols in the line (run)
    • Constructor Summary

      Constructors 
      Constructor Description
      Line​(LineEvaluator evaluator)
      Constructor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void append​(BoardPosition pos)
      Extend the line by an additional position.
      int computeValueDifference​(int position)
      We return the difference in value between how the board looked before the move was played (from both points of view) to after the move was played (from both points of view.
      java.lang.String toString()  
      void worthDebug​(java.lang.String dir, int pos, int diff)
      debugging aid
      • Methods inherited from class java.lang.Object

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

      • line

        protected java.lang.StringBuilder line
        contains the symbols in the line (run)
    • Constructor Detail

      • Line

        public Line​(LineEvaluator evaluator)
        Constructor
        Parameters:
        evaluator - used to evaluate the score for the line.
    • Method Detail

      • append

        public void append​(BoardPosition pos)
        Extend the line by an additional position.
        Parameters:
        pos - the position to extend ourselves by.
      • computeValueDifference

        public int computeValueDifference​(int position)
        We return the difference in value between how the board looked before the move was played (from both points of view) to after the move was played (from both points of view. It's important that we look at it from both sides because creating a near win is noticed from the moving players point of view while blocks are noted from the opposing viewpoint.
        Parameters:
        position - position in the string to compute value difference for.
        Returns:
        the difference in worth after making a move compared with before.
      • worthDebug

        public void worthDebug​(java.lang.String dir,
                               int pos,
                               int diff)
        debugging aid
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object