Class Patterns

  • Direct Known Subclasses:
    GoMokuPatterns, TicTacToePatterns

    public abstract class Patterns
    extends java.lang.Object
    Encapsulates the domain knowledge for n in a row game. These are key patterns that can occur in the game and are weighted by importance to let the computer play better. Do not add duplicate patterns or patterns that are the reverse of other patterns.
    • Field Detail

      • UNOCCUPIED

        public static final char UNOCCUPIED
        a blank space on the game board.
        See Also:
        Constant Field Values
    • Constructor Detail

      • Patterns

        public Patterns()
        Constructor.
    • Method Detail

      • getWeightIndexForPattern

        public int getWeightIndexForPattern​(java.lang.CharSequence pattern,
                                            int minpos,
                                            int maxpos)
        Parameters:
        pattern - pattern to get the weight index for.
        minpos - index of first character in pattern
        maxpos - index of last character position in pattern.
        Returns:
        weight index
      • getWeightIndexForPattern

        public int getWeightIndexForPattern​(java.lang.CharSequence pattern)
        Parameters:
        pattern - pattern to get the weight index for.
        Returns:
        weight index
      • getWinRunLength

        public abstract int getWinRunLength()
        Returns:
        how many in a row are needed to win. If M is five then the game is gomoku
      • getMinInterestingLength

        public abstract int getMinInterestingLength()
        Returns:
        patterns shorter than this are not interesting and have weight 0
      • getNumPatterns

        protected abstract int getNumPatterns()
        Returns:
        total number of patterns represented
      • initializePatterns

        protected void initializePatterns()
        Initialize all the gomoku patterns.
      • getPatternString

        protected abstract java.lang.String getPatternString​(int i)
      • getWeightIndex

        protected abstract int getWeightIndex​(int i)
      • setPatternWeightInTable

        protected void setPatternWeightInTable​(java.lang.String pattern,
                                               int wtIndex)