Class GoMokuBoard
- java.lang.Object
-
- com.barrybecker4.game.common.board.Board<M>
-
- com.barrybecker4.game.twoplayer.common.TwoPlayerBoard<TwoPlayerMove>
-
- com.barrybecker4.game.twoplayer.gomoku.GoMokuBoard
-
- All Implemented Interfaces:
IBoard<TwoPlayerMove>,IRectangularBoard<TwoPlayerMove>
- Direct Known Subclasses:
TicTacToeBoard
public class GoMokuBoard extends TwoPlayerBoard<TwoPlayerMove>
Representation of a GoMoku Game Board.
-
-
Field Summary
-
Fields inherited from class com.barrybecker4.game.common.board.Board
positions_
-
-
Constructor Summary
Constructors Modifier Constructor Description GoMokuBoard()default constructorGoMokuBoard(int numRows, int numCols)ConstructorprotectedGoMokuBoard(GoMokuBoard pb)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description GoMokuBoardcopy()We should be able to create a deep copy of ourselvesCandidateMovesgetCandidateMoves()intgetMaxNumMoves()There can be no more than this many moves in a game In many games, it is not just the number of squares.intgetNumPositionStates()Num different states.protected voidundoInternalMove(TwoPlayerMove move)For gomoku, undoing a move is just changing that space back to a blank.-
Methods inherited from class com.barrybecker4.game.twoplayer.common.TwoPlayerBoard
getStateIndex, makeInternalMove, makeMoves, toString
-
Methods inherited from class com.barrybecker4.game.common.board.Board
equals, getMoveList, getNumCols, getNumRows, getPosition, getPosition, getPositionPrototype, getTypicalNumMoves, hashCode, inBounds, isInCorner, isOnEdge, makeMove, reset, setPosition, setSize, undoMove
-
-
-
-
Constructor Detail
-
GoMokuBoard
public GoMokuBoard(int numRows, int numCols)Constructor- Parameters:
numRows- num rowsnumCols- num cols
-
GoMokuBoard
public GoMokuBoard()
default constructor
-
GoMokuBoard
protected GoMokuBoard(GoMokuBoard pb)
-
-
Method Detail
-
copy
public GoMokuBoard copy()
Description copied from interface:IRectangularBoardWe should be able to create a deep copy of ourselves- Specified by:
copyin interfaceIBoard<TwoPlayerMove>- Specified by:
copyin interfaceIRectangularBoard<TwoPlayerMove>- Specified by:
copyin classTwoPlayerBoard<TwoPlayerMove>- Returns:
- deep copy of the board.
-
getMaxNumMoves
public int getMaxNumMoves()
Description copied from interface:IRectangularBoardThere can be no more than this many moves in a game In many games, it is not just the number of squares. the main purpose of this function is to avoid cases where a game can go on forever by making repeat moves.- Returns:
- upper limit on the number of moves that the board can support
-
getCandidateMoves
public CandidateMoves getCandidateMoves()
-
undoInternalMove
protected void undoInternalMove(TwoPlayerMove move)
For gomoku, undoing a move is just changing that space back to a blank.- Specified by:
undoInternalMovein classBoard<TwoPlayerMove>- Parameters:
move- the move to undo
-
getNumPositionStates
public int getNumPositionStates()
Num different states. This is used primarily for the Zobrist hash. You do not need to override if yo udo not use it. States: player1, player2, empty.- Specified by:
getNumPositionStatesin classTwoPlayerBoard<TwoPlayerMove>- Returns:
- number of different states this position can have.
-
-