Package featurecat.lizzie.rules
Class BoardHistoryList
- java.lang.Object
-
- featurecat.lizzie.rules.BoardHistoryList
-
public class BoardHistoryList extends java.lang.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 void
add(BoardData data)
Add new data after head.void
addOrGoto(BoardData data)
void
addOrGoto(BoardData data, boolean newBranch)
void
clear()
Clear history.int
currentBranchLength()
Returns the length of current branchBoardHistoryNode
getCurrentHistoryNode()
BoardData
getData()
GameInfo
getGameInfo()
java.util.Optional<int[]>
getLastMove()
Stone
getLastMoveColor()
int
getMoveMNNumber()
int
getMoveNumber()
int[]
getMoveNumberList()
java.util.Optional<BoardData>
getNext()
Does not change the pointer positionjava.util.Optional<int[]>
getNextMove()
java.util.List<BoardHistoryNode>
getNexts()
java.util.Optional<BoardData>
getPrevious()
Does not change the pointer position.Stone[]
getStones()
Zobrist
getZobrist()
boolean
isBlacksTurn()
int
mainTrunkLength()
Returns the length of main trunkjava.util.Optional<BoardData>
next()
moves the pointer to the right, returns the data stored therejava.util.Optional<BoardData>
nextVariation(int idx)
Moves the pointer to the variation number idx, returns the data stored there.java.util.Optional<BoardData>
previous()
moves the pointer to the left, returns the data stored thereBoardHistoryNode
root()
Returns the root nodevoid
setGameInfo(GameInfo gameInfo)
void
setStone(int[] coordinates, Stone stone)
BoardHistoryList
shallowCopy()
void
toStart()
boolean
violatesKoRule(BoardData data)
boolean
violatesSuperko(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 java.util.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 java.util.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 java.util.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 java.util.Optional<BoardData> getNext()
Does not change the pointer position- Returns:
- the data stored at the next index, if any, Optional.empty otherwise.
-
getNexts
public java.util.List<BoardHistoryNode> getNexts()
- Returns:
- nexts for display
-
getPrevious
public java.util.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 java.util.Optional<int[]> getLastMove()
-
getNextMove
public java.util.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
-
-