Skip to content

Releases: jhlywa/chess.js

v1.0.0

11 Jan 00:45
Compare
Choose a tag to compare

v1.0.0

A big thank you to all the contributors that helped make this release possible! This is a major version update and there are many new features and breaking changes. Please read below for more info.

Typescript

chess.js has been rewritten in TypeScript. Exported types are as follows:

  • Chess class
  • Move class
  • Piece
  • Color
  • Square
  • PieceSymbol

New Methods

  • attackers(square, color) - returns a list of squares occupied by pieces of color that are attacking the given square
  • getCastlingRights(color) - returns { k: boolean, q: boolean } indicating castling rights for color
  • setCastlingRights(color, rights)
  • isAttacked(square, color) - returns true if square is attacked by color
  • isDrawByFiftyMoves()
  • moveNumber()
  • setHeader(key, value), removeHeader(key), getHeaders()
  • removeComment(), removeComments()

Breaking Changes

Exceptions instead of null

The following functions no longer return null when an error occurs. Instead, they now throw exceptions to provide the user with more detailed error information.

  • .load()
  • .loadPgn()
  • .move()
  • Chess() constructor

Function Names

The functions below have been converted to camel-case:

  • game_over -> isGameOver
  • in_check -> isCheck
  • in_checkmate -> isCheckmate
  • in_draw -> isDraw
  • is_stalemate -> isStalemate
  • in_threefold_repetition -> isThreefoldRepetition
  • insufficient_material -> isInsufficientMaterial
  • load_pgn -> loadPgn
  • set_comment -> setComment
  • get_comment -> getComment
  • get_comments -> getComments
  • delete_comment -> deleteComment
  • delete_comments -> deleteComments
  • validate_fen -> validateFen

Function Arguments and Return Values

The arguments and return values for the following functions have changed:

  • load_pgn(pgn, { sloppy: true }) becomes loadPgn(pgn) (strict defaults to false)
  • move('Nb7', { sloppy: true }) becomes moves('Nb7')
  • clear(true) should now be written as clear({ preserveHeader: true })
  • load(fen, true) should now be written as load(fen, { preserveHeader: true })
  • validateFen(fen) now returns { ok: boolean, error?: string }

Deprecations

  • The flags field in the Move object is deprecated. Use the new helper methods below to determine the move type:
    • .isCapture() - is the move a regular capture? NOTE: this is false for an en-passant
    • .isEnPassant() - is the move an en-passant capture?
    • .isBigPawn() - is the move a 2-rank pawn move?
    • .isPromotion() - is the move a pawn promotion?
    • .isKingsideCastle() - is the move a kingside castle?
    • .isQueensideCastle() - is the move a queenside castle?
  • The header function has been deprecated in favor of setHeader and getHeaders
  • The deleteComment and deleteComments functions have deprecated in favor of removeComment and removeComments

Improvements

  • Change .load to throw an exception when loading invalid FEN (@jhlywa - ac977ed )
  • Change .move to throw an exception on illegal move (@jhlywa - 8523db8)
  • Change .loadPgn to throw an exception when encountered error (@jhlywa - #TODO)
  • Allow the user to omit castling rights, en passant square, and move numbers when calling .load (@jhlywa - 8523db8)
  • Add isAttacked to determine attackers of a specific square (@jhlywa - 9b49454)
  • Validate king presence in validateFen (@jhlywa - a137478)
  • Allow spaces between the bracket and tag in PGN header (@jhlywa - 5f48a68)
  • Allow user to specify a promotion piece (when supplying a verbose move) even if the move is not a promotion (@jhlywa - 8e71084)
  • Add before and after FEN to Move object (@jhlywa - d42b0)
  • Add removeHeader method (@angarc - #388)
  • Fixed moves() when there are no kings (@neofight78 - #386)
  • Handle captures with missing ‘x’ (@neofight78 - #385)
  • Add methods for getting/setting castling rights (getCastlingRights, setCastlingRights) (@neofight78 - 7cb2d34)
  • Ensure put/remove functions update ep square (@neofight78 - #398 )
  • Make moveNumber accessible (@neofight78 - #399)
  • Add support for both ESM and CommonJS environments (@jorgecasar - #406)
  • Add check for invalid pawn placement in validateFen (@Manukyanq - #412)
  • Update castling rights and en passant square in .put() (@gavin-lb - 55181a9)
  • Add skipValidation option to .load (@jhlywa - e2ff91c)
  • Add isDrawByFiftyMoves (@HarshilPatel007 - #477)
  • Add type annotations (@HarshilPatel007 - #478)

Bug Fixes

v1.0.0-beta.7

17 Dec 02:05
Compare
Choose a tag to compare
v1.0.0-beta.7 Pre-release
Pre-release

Breaking Changes

These two changes only impact users that retain PGN headers when calling .clear or .load.

  • clear(true) should now be written as clear({ preserveHeader: true })
  • load(myFen, true) should now be written as load(myFen, { preserveHeader: true })

Enhancements

Bug Fixes

  • Fix README shield links (@JamJomJim - #416)
  • Fix three-fold repetition to only return true if the immediate position has been repeated 3 times (@gavin-lb - #144)
  • Update internal king cache when overwriting the king via put() (@Manukyanq #426)
  • Always clear Setup and FEN when calling .clear() (@jhlywa - be03fe0)

v1.0.0-beta.6

17 May 01:49
Compare
Choose a tag to compare
v1.0.0-beta.6 Pre-release
Pre-release

Enhancements

v1.0.0-beta.5

21 Apr 00:12
Compare
Choose a tag to compare
v1.0.0-beta.5 Pre-release
Pre-release

Enhancements

Bug Fixes

  • Revert module type to CommonJS (@jhlywa)

v1.0.0-beta.4

20 Mar 01:10
Compare
Choose a tag to compare
v1.0.0-beta.4 Pre-release
Pre-release

Enhancements

  • Add before and after FEN to Move object (@jhlywa)

Bug Fixes

v1.0.0-beta.3

03 Feb 11:36
Compare
Choose a tag to compare
v1.0.0-beta.3 Pre-release
Pre-release

Bug Fixes

v1.0.0-beta.2

19 Jan 13:12
Compare
Choose a tag to compare
v1.0.0-beta.2 Pre-release
Pre-release

Bug Fixes

v1.0.0-beta.1

15 Jan 02:57
Compare
Choose a tag to compare
v1.0.0-beta.1 Pre-release
Pre-release

Bug Fixes

  • Remove postinstall script
  • Add "types": "dist/chess.d.ts" entry to package.json

v1.0.0-beta.0

14 Jan 19:53
Compare
Choose a tag to compare
v1.0.0-beta.0 Pre-release
Pre-release

Changes

This is a major version update and there are many breaking changes. Please ead below for more info.

Typescript

chess.js has been rewritten in TypeScript. Exported types are as follows:

  • Chess object
  • Piece
  • Color
  • Square
  • PieceSymbol
  • Move

Exceptions

The following functions no longer return null in the event of an error. They now throw exceptions. This change was made to provide the user with more informative error messages.

  • .load()
  • .loadPgn()
  • .move()
  • Chess() constructor

Function Names

The functions below have been renamed and are now camel-cased:

  • game_over -> isGameOver
  • in_check -> isCheck
  • in_checkmate -> isCheckmate
  • in_draw -> isDraw
  • is_stalemate -> isStalemate
  • in_threefold_repetition -> isThreefoldRepetition
  • insufficient_material -> isInsufficientMaterial
  • load_pgn -> loadPgn
  • set_comment -> setComment
  • get_comment -> getComment
  • get_comments -> getComments
  • delete_comment -> deleteComment
  • delete_comments -> deleteComments
  • validate_fen -> validateFen

Improvements

  • Change .load to throw an exception when loading invalid FEN (#ac977ed)
  • Change .move to throw an exception on illegal move (#8523db8)
  • Change .loadPgn to throw an exception when encountered error (#TODO)
  • Allow the user to omit castling rights, en passant square, and move numbers when calling .load (#8523db8)
  • Add isAttacked to determine attackers of a specific square (#9b49454)
  • Validate king presence in validateFen (#a137478)
  • Allow spaces between the bracket and tag in PGN header (#5f48a68)
  • Allow user to specify a promotion piece (when supplying a verbose move) even if the move is not a promotion (#8e71084)
  • Add a fen field FEN position when calling .history

Bug Fixes

  • Fix loadPgn() to handle PGN without any moves (#d12f78f)
  • Fix pgn() export when comment precedes black to move (#4fd6069)

v1.0.0-alpha.0

14 Jan 19:52
Compare
Choose a tag to compare
v1.0.0-alpha.0 Pre-release
Pre-release
1.0.0-alpha.0