public class Position extends Object
Modifier and Type | Field and Description |
---|---|
static String |
START_POSITION_FEN
A FEN string for the starting chess position.
|
Constructor and Description |
---|
Position(Position pos)
Clones the specified position instance.
|
Modifier and Type | Method and Description |
---|---|
long |
getAllBlackOccupied() |
long |
getAllEmpty() |
long |
getAllNonBlackOccupied() |
long |
getAllNonWhiteOccupied() |
long |
getAllOccupied() |
long |
getAllWhiteOccupied() |
long |
getBlackBishops() |
byte |
getBlackCastlingRights() |
long |
getBlackKing() |
long |
getBlackKnights() |
long |
getBlackPawns() |
long |
getBlackQueens() |
long |
getBlackRooks() |
long |
getCheckers() |
byte |
getEnPassantRights() |
byte |
getFiftyMoveRuleClock() |
int |
getHalfMoveIndex() |
long |
getKey() |
Move |
getLastMove() |
PositionStateRecord |
getLastState() |
ArrayDeque<Move> |
getMoveHistory() |
List<Move> |
getMoves()
Returns a list of all the legal moves in the current position.
|
short |
getPhaseScore() |
byte |
getPiece(int sqrInd) |
List<Move> |
getQuietMoves()
Returns a list of all the legal quiet moves in the current position.
|
ArrayDeque<PositionStateRecord> |
getStateHistory() |
List<Move> |
getTacticalMoves()
Returns a list of all the legal tactical moves in the current position.
|
long |
getWhiteBishops() |
byte |
getWhiteCastlingRights() |
long |
getWhiteKing() |
long |
getWhiteKnights() |
long |
getWhitePawns() |
long |
getWhiteQueens() |
long |
getWhiteRooks() |
boolean |
givesCheck(Move move)
Checks whether the specified move puts the opponent in check.
|
boolean |
hasRepeated(int numberOfTimes) |
boolean |
isInCheck() |
boolean |
isLegal(Move move)
Determines whether the move is legal in the current position.
|
boolean |
isWhitesTurn() |
void |
makeMove(Move move)
Makes the specified move.
|
void |
makeNullMove()
Makes a null move.
|
static Position |
parse(String fen)
It parses a FEN string and initializes a position instance based on it.
|
String |
toString() |
Move |
unmakeMove()
Takes back the last move made and returns it.
|
public static final String START_POSITION_FEN
public Position(Position pos)
pos
- The position to clone.public static Position parse(String fen) throws ChessParseException
fen
- The FEN string.ChessParseException
- If the string is invalid.public long getWhiteKing()
public long getWhiteQueens()
public long getWhiteRooks()
public long getWhiteBishops()
public long getWhiteKnights()
public long getWhitePawns()
public long getBlackKing()
public long getBlackQueens()
public long getBlackRooks()
public long getBlackBishops()
public long getBlackKnights()
public long getBlackPawns()
public long getAllWhiteOccupied()
public long getAllBlackOccupied()
public long getAllNonWhiteOccupied()
public long getAllNonBlackOccupied()
public long getAllOccupied()
public long getAllEmpty()
public long getCheckers()
public boolean isInCheck()
public boolean isWhitesTurn()
public byte getPiece(int sqrInd)
sqrInd
- The index of the square.public short getPhaseScore()
public int getHalfMoveIndex()
public byte getFiftyMoveRuleClock()
public byte getEnPassantRights()
public byte getWhiteCastlingRights()
public byte getBlackCastlingRights()
public long getKey()
public ArrayDeque<Move> getMoveHistory()
public Move getLastMove()
public ArrayDeque<PositionStateRecord> getStateHistory()
public PositionStateRecord getLastState()
public boolean hasRepeated(int numberOfTimes)
numberOfTimes
- The hypothetical number of times the position has occurred before. E.g. for a three-fold repetition check, it
would be 2.public void makeMove(Move move)
move
- The move to make.public void makeNullMove()
public Move unmakeMove()
public boolean givesCheck(Move move)
move
- The move to check.public boolean isLegal(Move move)
move
- The move to perform legality check on.public List<Move> getTacticalMoves()
public List<Move> getQuietMoves()
public List<Move> getMoves()
Copyright © 2020. All rights reserved.