Class LineEvaluator
- java.lang.Object
-
- com.barrybecker4.game.twoplayer.gomoku.analysis.LineEvaluator
-
public class LineEvaluator extends java.lang.ObjectTest that we can correctly evaluate a run of symbols on the board.
-
-
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 intevaluate(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.intgetMinInterestingLength()protected java.lang.CharSequencegetPattern(java.lang.CharSequence line, char opponentSymb, int pos, int minpos, int maxpos)protected intgetWeightIndex(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.
-
-
-
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 evaluateplayer1Perspective- 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 evaluatemaxpos- 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)
-
-