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
addNodeProperty(java.lang.String key, java.lang.String value)
void
addOrGoto(BoardData data)
void
addOrGoto(BoardData data, boolean newBranch)
void
addOrGoto(BoardData data, boolean newBranch, boolean changeMove)
void
addStone(int x, int y, Stone color)
void
clear()
Clear history.int
currentBranchLength()
Returns the length of current branchvoid
flatten()
BoardHistoryNode
getCurrentHistoryNode()
BoardData
getData()
BoardHistoryNode
getEnd()
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<BoardData>
getNext(boolean includeDummy)
java.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
goToMoveNumber(int moveNumber, boolean withinBranch)
boolean
isBlacksTurn()
int
mainTrunkLength()
Returns the length of main trunkvoid
moveNumber(int moveNumber)
java.util.Optional<BoardData>
next()
moves the pointer to the right, returns the data stored therejava.util.Optional<BoardData>
next(boolean includeDummay)
java.util.Optional<BoardData>
nextVariation(int idx)
Moves the pointer to the variation number idx, returns the data stored there.void
pass(Stone color)
void
pass(Stone color, boolean newBranch)
void
pass(Stone color, boolean newBranch, boolean dummy)
void
pass(Stone color, boolean newBranch, boolean dummy, boolean changeMove)
void
place(int x, int y, Stone color)
void
place(int x, int y, Stone color, boolean newBranch)
void
place(int x, int y, Stone color, boolean newBranch, boolean changeMove)
java.util.Optional<BoardData>
previous()
moves the pointer to the left, returns the data stored therevoid
removeStone(int x, int y, Stone color)
BoardHistoryNode
root()
Returns the root nodevoid
setGameInfo(GameInfo gameInfo)
void
setStone(int[] coordinates, Stone stone)
BoardHistoryList
shallowCopy()
int
sync(BoardHistoryList newList)
void
toBranchTop()
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)
-
addOrGoto
public void addOrGoto(BoardData data, boolean newBranch, boolean changeMove)
-
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()
-
toBranchTop
public void toBranchTop()
-
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
-
next
public java.util.Optional<BoardData> next(boolean includeDummay)
-
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.
-
getNext
public java.util.Optional<BoardData> getNext(boolean includeDummy)
-
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
-
getEnd
public BoardHistoryNode getEnd()
-
pass
public void pass(Stone color)
-
pass
public void pass(Stone color, boolean newBranch)
-
pass
public void pass(Stone color, boolean newBranch, boolean dummy)
-
pass
public void pass(Stone color, boolean newBranch, boolean dummy, boolean changeMove)
-
place
public void place(int x, int y, Stone color)
-
place
public void place(int x, int y, Stone color, boolean newBranch)
-
place
public void place(int x, int y, Stone color, boolean newBranch, boolean changeMove)
-
addNodeProperty
public void addNodeProperty(java.lang.String key, java.lang.String value)
-
moveNumber
public void moveNumber(int moveNumber)
-
addStone
public void addStone(int x, int y, Stone color)
-
removeStone
public void removeStone(int x, int y, Stone color)
-
flatten
public void flatten()
-
goToMoveNumber
public boolean goToMoveNumber(int moveNumber, boolean withinBranch)
-
sync
public int sync(BoardHistoryList newList)
-
-