Package io.github.wolfraam.chessgame
Class ChessGame
java.lang.Object
io.github.wolfraam.chessgame.ChessGame
- All Implemented Interfaces:
Serializable,Cloneable
A Chess Game.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()Clones the chess game.getASCII()getFen()A shorter version of FEN, without new lines and slashes and which combines empty squares across files.intThe number of the full moves.The result of the game as determined by the board.The result of the game as determined by the board.The fen of the board before move 1.The last played move, or null if no moves have been played.getLegalMoves(Square from) getMove(NotationType notationType, String move) getMove(NotationType notationType, String languageCode, String move) getMoves()getNotation(NotationType notationType, Move move) getNotation(NotationType notationType, String languageCode, Move move) getNotationList(NotationType notationType) getNotationList(NotationType notationType, String languageCode) intgetScore()The current score.getSquares(Piece piece) getSubset(int moveCount) booleanbooleanisLegalMove(Move move) voidplayMove(NotationType notationType, String move) Plays the move given in the notation type.voidplayMove(NotationType notationType, String languageCode, String move) Plays the move given in the language and notation type.voidplayMoves(NotationType notationType, String movesArgument) Plays the moves given in notation type.voidplayMoves(NotationType notationType, String languageCode, String movesArgument) Plays the moves given in the notation type and language.voidplayMoves(NotationType notationType, List<String> moveList) Plays the moves given in the notation type.voidplayMoves(String languageCode, NotationType notationType, List<String> moveList) Plays the moves given in the notation type and language.
-
Field Details
-
STANDARD_INITIAL_FEN
- See Also:
-
-
Constructor Details
-
ChessGame
public ChessGame()Constructs a chess game with the initial position. -
ChessGame
Constructs a chess game with the starting position of the fen argument.
-
-
Method Details
-
clone
Clones the chess game. -
getASCII
- Returns:
- an ascii representation of the board
-
getAvailablePGNTags
- Returns:
- a set of all the PGN tags available. These are filled when a PGN import has been done.
-
getCapturedPieces
- Returns:
- a list of all captured pieces in the order in which they were captured.
-
getChessOpening
- Returns:
- the chess opening for this game.
-
getFen
- Returns:
- the current board in FEN notation (Forsyth-Edwards Notation)
-
getFenSmall
A shorter version of FEN, without new lines and slashes and which combines empty squares across files. -
getFullMoveCount
public int getFullMoveCount()The number of the full moves. It starts at 1 and is incremented after Black's move. -
getGameResult
The result of the game as determined by the board. This does NOT take the "Result" tag of an PGN import into account. Returns null if there is no result yet. -
getGameResultType
The result of the game as determined by the board. This does NOT take the "Result" tag of an PGN import into account. Returns null if there is no result yet. -
getInitialFen
The fen of the board before move 1. -
getLastMove
The last played move, or null if no moves have been played. -
getLegalMoves
- Returns:
- all legal moves for the current position.
-
getLegalMoves
- Returns:
- all legal moves for the piece on the square.
-
getMove
- Returns:
- the Move parsed by the rules of the notationType
- Throws:
IllegalMoveException- if the notation is not correct
-
getMove
public Move getMove(NotationType notationType, String languageCode, String move) throws IllegalMoveException - Returns:
- the Move parsed by the rules of the notationType and the given language
- Throws:
IllegalMoveException- if the notation is not correct
-
getMoves
- Returns:
- all played moves of this game.
-
getNotation
- Returns:
- the notation of the move in the given notationType
-
getNotation
- Returns:
- the notation of the move in the given notationType and language
-
getNotationList
- Returns:
- all played moves of this game in the given notationType
-
getNotationList
- Returns:
- all played moves of this game in the given notationType and language
-
getOccupiedSquares
- Returns:
- the occupied squares of the current board
-
getPGNData
- Returns:
- the PGNData.
-
getPiece
- Returns:
- piece on the square of the current board.
-
getScore
public int getScore()The current score. Returns a positive integer when white has captured more, negative when black has captured more and 0 when black and white have captured the same. pawn = 1, knight = 3, bishop = 3, rook = 5, queen = 9 -
getSideToMove
- Returns:
- the side whose turn it is to move.
-
getSquares
- Returns:
- all the squares where the given piece is on the board
-
getSquaresAttackingKing
- Returns:
- all the squares of pieces which are checking the opposing king
-
getSubset
- Returns:
- a new chess game which a subset of the moves of this game.
-
isKingAttacked
public boolean isKingAttacked()- Returns:
- is the king checked?
-
isLegalMove
- Returns:
- whether the move is legal.
-
playMove
- Returns:
- plays the move. Does NOT check whether the move is legal.
-
playMove
Plays the move given in the notation type.- Throws:
IllegalMoveException- if the notation is not correct
-
playMove
public void playMove(NotationType notationType, String languageCode, String move) throws IllegalMoveException Plays the move given in the language and notation type.- Throws:
IllegalMoveException- if the notation is not correct
-
playMoves
Plays the moves given in notation type.- Parameters:
movesArgument- the moves space or comma seperated- Throws:
IllegalMoveException- if a notation is not correct
-
playMoves
Plays the moves given in the notation type.- Throws:
IllegalMoveException- if a notation is not correct
-
playMoves
public void playMoves(NotationType notationType, String languageCode, String movesArgument) throws IllegalMoveException Plays the moves given in the notation type and language.- Parameters:
movesArgument- the moves space or comma seperated- Throws:
IllegalMoveException- if a notation is not correct
-
playMoves
public void playMoves(String languageCode, NotationType notationType, List<String> moveList) throws IllegalMoveException Plays the moves given in the notation type and language.- Throws:
IllegalMoveException- if a notation is not correct
-