Package featurecat.lizzie.rules
Class BoardHistoryList
- java.lang.Object
-
- featurecat.lizzie.rules.BoardHistoryList
-
public class BoardHistoryList extends Object
Linked list data structure to store board history
-
-
Constructor Summary
Constructors Constructor Description BoardHistoryList(BoardData data)Initialize a new board history list, whose first node is data
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(BoardData data)Add new data after head.voidaddOrGoto(BoardData data)voidaddOrGoto(BoardData data, boolean newBranch)voidclear()Clear history.intcurrentBranchLength()Returns the length of current branchBoardHistoryNodegetCurrentHistoryNode()BoardDatagetData()GameInfogetGameInfo()Optional<int[]>getLastMove()StonegetLastMoveColor()intgetMoveMNNumber()intgetMoveNumber()int[]getMoveNumberList()Optional<BoardData>getNext()Does not change the pointer positionOptional<int[]>getNextMove()List<BoardHistoryNode>getNexts()Optional<BoardData>getPrevious()Does not change the pointer position.Stone[]getStones()ZobristgetZobrist()booleanisBlacksTurn()intmainTrunkLength()Returns the length of main trunkOptional<BoardData>next()moves the pointer to the right, returns the data stored thereOptional<BoardData>nextVariation(int idx)Moves the pointer to the variation number idx, returns the data stored there.Optional<BoardData>previous()moves the pointer to the left, returns the data stored thereBoardHistoryNoderoot()Returns the root nodevoidsetGameInfo(GameInfo gameInfo)voidsetStone(int[] coordinates, Stone stone)BoardHistoryListshallowCopy()voidtoStart()booleanviolatesKoRule(BoardData data)booleanviolatesSuperko(BoardData data)
-
-
-
Constructor Detail
-
BoardHistoryList
public BoardHistoryList(BoardData data)
Initialize a new board history list, whose first node is data- Parameters:
data- the data to be stored for the first entry
-
-
Method Detail
-
getGameInfo
public GameInfo getGameInfo()
-
setGameInfo
public void setGameInfo(GameInfo gameInfo)
-
shallowCopy
public BoardHistoryList shallowCopy()
-
clear
public void clear()
Clear history.
-
add
public void add(BoardData data)
Add new data after head. Overwrites any data that may have been stored after head.- Parameters:
data- the data to add
-
addOrGoto
public void addOrGoto(BoardData data)
-
addOrGoto
public void addOrGoto(BoardData data, boolean newBranch)
-
previous
public Optional<BoardData> previous()
moves the pointer to the left, returns the data stored there- Returns:
- data of previous node, Optional.empty if there is no previous node
-
toStart
public void toStart()
-
next
public Optional<BoardData> next()
moves the pointer to the right, returns the data stored there- Returns:
- the data of next node, Optional.empty if there is no next node
-
nextVariation
public Optional<BoardData> nextVariation(int idx)
Moves the pointer to the variation number idx, returns the data stored there.- Returns:
- the data of next node, Optional.empty if there is no variation with index.
-
getNext
public Optional<BoardData> getNext()
Does not change the pointer position- Returns:
- the data stored at the next index, if any, Optional.empty otherwise.
-
getNexts
public List<BoardHistoryNode> getNexts()
- Returns:
- nexts for display
-
getPrevious
public Optional<BoardData> getPrevious()
Does not change the pointer position.- Returns:
- the data stored at the previous index, if any, Optional.empty otherwise.
-
getData
public BoardData getData()
- Returns:
- the data of the current node
-
setStone
public void setStone(int[] coordinates, Stone stone)
-
getStones
public Stone[] getStones()
-
getLastMove
public Optional<int[]> getLastMove()
-
getNextMove
public Optional<int[]> getNextMove()
-
getLastMoveColor
public Stone getLastMoveColor()
-
isBlacksTurn
public boolean isBlacksTurn()
-
getZobrist
public Zobrist getZobrist()
-
getMoveNumber
public int getMoveNumber()
-
getMoveMNNumber
public int getMoveMNNumber()
-
getMoveNumberList
public int[] getMoveNumberList()
-
getCurrentHistoryNode
public BoardHistoryNode getCurrentHistoryNode()
-
violatesSuperko
public boolean violatesSuperko(BoardData data)
- Parameters:
data- the board position to check against superko- Returns:
- whether or not the given position violates the superko rule at the head's state
-
violatesKoRule
public boolean violatesKoRule(BoardData data)
-
root
public BoardHistoryNode root()
Returns the root node- Returns:
- root node
-
currentBranchLength
public int currentBranchLength()
Returns the length of current branch- Returns:
- length of current branch
-
mainTrunkLength
public int mainTrunkLength()
Returns the length of main trunk- Returns:
- length of main trunk
-
-