Class Patterns
- java.lang.Object
-
- com.barrybecker4.game.twoplayer.gomoku.pattern.Patterns
-
- Direct Known Subclasses:
GoMokuPatterns,TicTacToePatterns
public abstract class Patterns extends java.lang.ObjectEncapsulates 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 Summary
Fields Modifier and Type Field Description static charUNOCCUPIEDa blank space on the game board.
-
Constructor Summary
Constructors Constructor Description Patterns()Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract intgetMinInterestingLength()protected abstract intgetNumPatterns()protected abstract java.lang.StringgetPatternString(int i)protected abstract intgetWeightIndex(int i)intgetWeightIndexForPattern(java.lang.CharSequence pattern)intgetWeightIndexForPattern(java.lang.CharSequence pattern, int minpos, int maxpos)abstract intgetWinRunLength()protected voidinitializePatterns()Initialize all the gomoku patterns.protected voidsetPatternWeightInTable(java.lang.String pattern, int wtIndex)
-
-
-
Field Detail
-
UNOCCUPIED
public static final char UNOCCUPIED
a blank space on the game board.- See Also:
- Constant Field Values
-
-
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 patternmaxpos- 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)
-
-