{"_id":"@augerm/chess.ts","_rev":"3-cdba15defdb158403060a7100e5b7aca","name":"@augerm/chess.ts","dist-tags":{"latest":"0.0.3"},"versions":{"0.0.1":{"name":"@augerm/chess.ts","version":"0.0.1","license":"BSD-2-Clause","main":"dist/chess.js","tpyes":"dist/index.d.ts","devDependencies":{"jest":"^27.0.1","prettier":"^2.2.1","tslint":"^6.1.3","typescript":"^4.5.3"},"scripts":{"build":"tsc","watch":"tsc --watch","lint":"tslint -c tslint.json 'src/**/*.ts'","lint-fix":"yarn lint --fix","prepublish":"yarn build","release":"yarn publish --access=public"},"description":"[![Build Status](https://travis-ci.org/jhlywa/chess.js.svg?branch=master)](https://travis-ci.org/jhlywa/chess.js)","licenseText":"Copyright (c) 2021, Jeff Hlywa (jhlywa@gmail.com)\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n1. Redistributions of source code must retain the above copyright notice,\n   this list of conditions and the following disclaimer.\n2. Redistributions in binary form must reproduce the above copyright notice,\n   this list of conditions and the following disclaimer in the documentation\n   and/or other materials provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\nAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\nARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\nLIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\nINTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\nCONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\nARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\nPOSSIBILITY OF SUCH DAMAGE.\n","_id":"@augerm/chess.ts@0.0.1","dist":{"shasum":"e733735eaacc86aa862211feee3b94a6888f737b","integrity":"sha512-p2HP0/odt9B+3DpNTMlj4Bhcakk4B0q2Cf9qocwEywg7NwYw5pKpPfu8QT0f1+mqps6bK91LbLMWMz1AuyUZ4w==","tarball":"https://registry.npmjs.org/@augerm/chess.ts/-/chess.ts-0.0.1.tgz","fileCount":16,"unpackedSize":237820,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhtNiHCRA9TVsSAnZWagAACyEP/RMnhKdQAH3iiT7JJmzi\nLoAQRaQL1uPM/15SkmW0nhQ3mng1I+dDbtUCfNe63XVHZY0Qm24ClFGIhdqG\n0gtIm5iECaQRoLlfU1GAYZq4XLK5Lu5SdHdovvLibkzkAxAOc+mGJIIBpq8V\njHFpUhAw7LX8AJ8lsARHHEG8iWSB1RIUQHeEvCfI5I6ruPRECHvF4Ts9QF4E\n3JpqsCS0QVoRMTbTYDlqP+PTrORXFS7A4Qbq2ynmNV/RqHv3MEa4KVW08iMG\nS0d9UVu24amsdSNIUqroMzrawXyo9ar9r8+x5ya4+Ze+NWpuvUo6EyrKBXPt\nmCXFN32YAKhq1mlVANgPHQjOLMxLflmdhHWXLfLpPIpZrDoslQeCIBUI2LND\n43xRaoccyEdiO/PL4IWSISFYMtvipcZ8UHZFG2BsEmJxqGkkio9W2ZD8uY0l\nGW38Yqe3jrY47Rncs24Xyf7LX7BgGGhwsJMvpMJFv5IDn5CN5byoa/lmG1UQ\nqPpahTvQRvhOOq+b8SCmIMTHe8WSq7UdO+jrDULOXEnQ1le0342NT3CZc7J2\nak6ds1x7ivzhPnllAY1I3RHTlNEC4nRdhmzLGPeIs55TLHTNk4MEyJFpPSw0\nsm1zw1DJ1cVxxVVxQC+wyxUoUBgHBOS0T8gdp88VMyRsEpD1l5IpTCV+ucR/\n7lwK\r\n=0Utb\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCg3701xEmc2bpSuJ620uOVqcDsznCwpWlxYhJyzEsZUAIhANldVofY06LM4BESE+Ifu9eSKSqE3B3gC6NL9QkUjQPi"}]},"_npmUser":{"name":"augerm","email":"michaelauger23@gmail.com"},"directories":{},"maintainers":[{"name":"augerm","email":"michaelauger23@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/chess.ts_0.0.1_1639241863571_0.2345768216426083"},"_hasShrinkwrap":false},"0.0.2":{"name":"@augerm/chess.ts","version":"0.0.2","license":"BSD-2-Clause","main":"dist/chess.js","tpyes":"dist/index.d.ts","devDependencies":{"tslint":"^6.1.3","typescript":"^4.5.3"},"scripts":{"build":"tsc","watch":"tsc --watch","lint":"tslint -c tslint.json 'src/**/*.ts'","lint-fix":"yarn lint --fix","prepublish":"yarn build","release":"yarn publish --access=public"},"description":"[![Build Status](https://travis-ci.org/jhlywa/chess.js.svg?branch=master)](https://travis-ci.org/jhlywa/chess.js)","licenseText":"Copyright (c) 2021, Jeff Hlywa (jhlywa@gmail.com)\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n1. Redistributions of source code must retain the above copyright notice,\n   this list of conditions and the following disclaimer.\n2. Redistributions in binary form must reproduce the above copyright notice,\n   this list of conditions and the following disclaimer in the documentation\n   and/or other materials provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\nAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\nARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\nLIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\nINTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\nCONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\nARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\nPOSSIBILITY OF SUCH DAMAGE.\n","_id":"@augerm/chess.ts@0.0.2","dist":{"shasum":"d0a2e3443f350ef42e1a8bbb28798aa5c0cd06aa","integrity":"sha512-t0Th+jDRLQFeM5cLn8TGdllY10S9G59uFhwcJXq8QwargynY6st9K4FfPYmPAEUn4SKsp2hxJgCcaPVj3K9Dwg==","tarball":"https://registry.npmjs.org/@augerm/chess.ts/-/chess.ts-0.0.2.tgz","fileCount":14,"unpackedSize":237371,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhtNqFCRA9TVsSAnZWagAAZs4P/jumnAMYluXBGl1Ja5h2\nt7rIbvjZsqHH83L3dCJ2ZdiKbR1U7uDEj5QH0Dh3aVqvyY8T3DJWGUsw6EZI\n644PeKACTvuoznB3Szmjaugd4TpZROf8Y98Yx2BfZaVbDDz3m68LkzEl9QbQ\nPHuNHCBnh1kMSwLErlGZfHuCLJ5IwxgiG9kEMn9PMBxeFChPrpurpvLCz2cl\ntauihUBRO35+oS9w3JnczXri0yQGWUfMbX1yxR2UWELsV7VDjA2wXW/cxdFf\nv8mip/BBk5Q7Y/APMLdlmGj9iBhtUCXpcBiAC+kyjHBlW+KjcRj4Eg+qYe6f\ng6Tfw7ofR7iL7FHGPyHhhZQ8v5B2lh52DtsA/Nx+uzQz1Dvuz2TfDo/jCSe0\nXTs4I8OhqyI8UdwMk5RyPcolHJoo8WGX6f8w8IgNF5KhHUpSuiyMASRdKNW8\n7cWKBVze8IgdB3zOC6ERTFi/f4ZpWjjfpWOyApulQhksK3AYxFKwVQT5WLbx\naTu2YW9wJcb5zg8V2DQAfdpzeMzbFraq5hBYJ73v7Xxu1849yDUExtqr9CDk\nnWMKM++X/0IRpJ+TDxK9xDxhaWneUqrEsPYD5KxPDy4QedrSqKTGYLJuVthl\nQDH17wVZwlTcO2qzFetPej4jwUJBFF49+raCN75LCmsbeLInAdpBnkRtTFuP\nCwoJ\r\n=wFIm\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCLhYoJdjOMNyY76SHfYKV4dhs6LVczGats7QOBL9QpXgIgVzmp/HQ+L5bi7XlRWA6sEPAhLjxKl3Sq8z2Lpduq4kc="}]},"_npmUser":{"name":"augerm","email":"michaelauger23@gmail.com"},"directories":{},"maintainers":[{"name":"augerm","email":"michaelauger23@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/chess.ts_0.0.2_1639242373081_0.27239498998886624"},"_hasShrinkwrap":false},"0.0.3":{"name":"@augerm/chess.ts","version":"0.0.3","license":"BSD-2-Clause","main":"dist/chess.js","tpyes":"dist/index.d.ts","devDependencies":{"@babel/core":"^7.16.7","@babel/preset-env":"^7.16.7","@babel/preset-typescript":"^7.16.7","@types/jest":"^27.4.0","babel-jest":"^27.4.5","jest":"^27.4.5","ts-jest":"^27.1.2","ts-node":"^10.4.0","tslint":"^6.1.3","typescript":"^4.5.3"},"scripts":{"build":"tsc","watch":"tsc --watch","lint":"tslint -c tslint.json 'src/**/*.ts'","lint-fix":"yarn lint --fix","prepublish":"yarn build","release":"yarn publish --access=public","test":"jest","test-watch":"jest --watchAll"},"description":"[![Build Status](https://travis-ci.org/jhlywa/chess.js.svg?branch=master)](https://travis-ci.org/jhlywa/chess.js)","licenseText":"Copyright (c) 2021, Jeff Hlywa (jhlywa@gmail.com)\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n1. Redistributions of source code must retain the above copyright notice,\n   this list of conditions and the following disclaimer.\n2. Redistributions in binary form must reproduce the above copyright notice,\n   this list of conditions and the following disclaimer in the documentation\n   and/or other materials provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\nAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\nARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\nLIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\nINTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\nCONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\nARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\nPOSSIBILITY OF SUCH DAMAGE.\n","_id":"@augerm/chess.ts@0.0.3","dist":{"shasum":"a15fcb7a780e8851a0b312c3bac84d0250295750","integrity":"sha512-VHk7DMEo32RiwZYnygGXOoLP6051iL1i+WIZ2BX9WzLOdac9pAJBYcE9lR1dItIToeQ/ub4n7Io0GcNnj8AFAg==","tarball":"https://registry.npmjs.org/@augerm/chess.ts/-/chess.ts-0.0.3.tgz","fileCount":31,"unpackedSize":855472,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhznsTCRA9TVsSAnZWagAAMwwP/3hegGZq6H9qTvZgzKG7\nWMJSDBpg/iJxbYI3BNUAjr6qwKihx2DWUCWHiW4Cd6FxOzC5XvmnoG/YbaC9\nO4Lty59j4qg1/hdpRgM07UERlAMGto7uI7oawpccOMKv94ASVo6Un8h8IGDJ\nzyz8dGOuvJwXpDOc27KWnHpDEbzDMACALBvhX05bknsXo2cRAiGDwQZxHkKF\n6YSwu1OoSK2HtBnwpnmz3z+/O5winoqiSXX2jmz+6rcM0BTxde8kopqDXA0j\nzLgrCui0uTlE01rKgVwN1kpN3jL+enHm+8Lr06RkJGJwdTby5qiszUP7qmlv\nJtGzbTf8N+Po39kW/FyeBDX1ZNimfVCiXrMF2ljJ4Dcn/8Mdp53TazJcPiop\niAuF2Zl97Pn3wsNLBLcyVgdM1boITnD8NTsL5K8RvFIsb5Yf3XQ0+mio+p4G\nP48zfSOh8iSH/235yRqgq3imatoqPIclOFMA+4VOVRS7BURsnoSnIwgvfd0u\nLiZSi0ujY0OXwUfw0l4aLPw7sQhAHSICFgAUvvHN+5tmcl5amOKEg8iaywDx\nL47A/AIABXDdcsWQAb9Ywt6ytGX1v7OMRNPVt8nSA2NouiiMPeHmxmlHJrcr\na+6/zmL8493f0B7vRByjvSLKLs+fgXOmTKWXWYAJZLyEiAtC5Uk7MTAM0NJR\nSpDL\r\n=gldx\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEzFMBMlS4nEpPPT4UEWIPkFTzMV694+tjtxSpcpmOqbAiBu38Bh+tzqUXfXM3cXUEI9fgoWl+pt65bjN3Htof6WSg=="}]},"_npmUser":{"name":"augerm","email":"michaelauger23@gmail.com"},"directories":{},"maintainers":[{"name":"augerm","email":"michaelauger23@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/chess.ts_0.0.3_1640921875681_0.6315321606834443"},"_hasShrinkwrap":false}},"time":{"created":"2021-12-11T16:57:43.522Z","0.0.1":"2021-12-11T16:57:43.729Z","modified":"2022-04-04T16:23:16.854Z","0.0.2":"2021-12-11T17:06:13.282Z","0.0.3":"2021-12-31T03:37:55.850Z"},"maintainers":[{"name":"augerm","email":"michaelauger23@gmail.com"}],"description":"[![Build Status](https://travis-ci.org/jhlywa/chess.js.svg?branch=master)](https://travis-ci.org/jhlywa/chess.js)","license":"BSD-2-Clause","readme":"# chess.js\n\n[![Build Status](https://travis-ci.org/jhlywa/chess.js.svg?branch=master)](https://travis-ci.org/jhlywa/chess.js)\n\nchess.js is a Javascript chess library that is used for chess move\ngeneration/validation, piece placement/movement, and check/checkmate/stalemate\ndetection - basically everything but the AI.\n\nchess.js has been extensively tested in node.js and most modern browsers.\n\n## Installation\n\nTo install the stable version:\n\n```\n# NPM\nnpm install chess.js\n\n# Yarn\nyarn add chess.js\n```\n\n## Example Code\n\nThe code below plays a random game of chess:\n\n```js\nconst { Chess } = require('./chess.js')\nconst chess = new Chess()\n\nwhile (!chess.game_over()) {\n    const moves = chess.moves()\n    const move = moves[Math.floor(Math.random() * moves.length)]\n    chess.move(move)\n}\nconsole.log(chess.pgn())\n```\n\n## User Interface\n\nBy design, chess.js is headless and does not include user interface.  Many\ndevelopers have had success integrating chess.js with the\n[chessboard.js](http://chessboardjs.com) library. See\n[chessboard.js - Random vs Random](http://chessboardjs.com/examples#5002) for\nan example.\n\n## API\n\n### Constructor: Chess([ fen ])\n\nThe Chess() constructor takes an optional parameter which specifies the board configuration\nin [Forsyth-Edwards Notation](http://en.wikipedia.org/wiki/Forsyth%E2%80%93Edwards_Notation).\n\n```js\n// board defaults to the starting position when called with no parameters\nconst chess = new Chess()\n\n// pass in a FEN string to load a particular position\nconst chess = new Chess(\n    'r1k4r/p2nb1p1/2b4p/1p1n1p2/2PP4/3Q1NB1/1P3PPP/R5K1 b - c3 0 19'\n)\n```\n\n### .ascii()\n\nReturns a string containing an ASCII diagram of the current position.\n\n```js\nconst chess = new Chess()\n\n// make some moves\nchess.move('e4')\nchess.move('e5')\nchess.move('f4')\n\nchess.ascii()\n// -> '   +------------------------+\n//      8 | r  n  b  q  k  b  n  r |\n//      7 | p  p  p  p  .  p  p  p |\n//      6 | .  .  .  .  .  .  .  . |\n//      5 | .  .  .  .  p  .  .  . |\n//      4 | .  .  .  .  P  P  .  . |\n//      3 | .  .  .  .  .  .  .  . |\n//      2 | P  P  P  P  .  .  P  P |\n//      1 | R  N  B  Q  K  B  N  R |\n//        +------------------------+\n//          a  b  c  d  e  f  g  h'\n```\n\n### .board()\n\nReturns an 2D array representation of the current position. Empty squares are\nrepresented by `null`.\n\n```js\nconst chess = new Chess()\n\nchess.board()\n// -> [[{type: 'r', color: 'b'},\n        {type: 'n', color: 'b'},\n        {type: 'b', color: 'b'},\n        {type: 'q', color: 'b'},\n        {type: 'k', color: 'b'},\n        {type: 'b', color: 'b'},\n        {type: 'n', color: 'b'},\n        {type: 'r', color: 'b'}],\n        [...],\n        [...],\n        [...],\n        [...],\n        [...],\n        [{type: 'r', color: 'w'},\n         {type: 'n', color: 'w'},\n         {type: 'b', color: 'w'},\n         {type: 'q', color: 'w'},\n         {type: 'k', color: 'w'},\n         {type: 'b', color: 'w'},\n         {type: 'n', color: 'w'},\n         {type: 'r', color: 'w'}]]\n```\n\n### .clear()\n\nClears the board.\n\n```js\nchess.clear()\nchess.fen()\n// -> '8/8/8/8/8/8/8/8 w - - 0 1' <- empty board\n```\n\n### .delete_comment()\n\nDelete and return the comment for the current position, if it exists.\n\n```js\nconst chess = new Chess()\n\nchess.load_pgn(\"1. e4 e5 2. Nf3 Nc6 3. Bc4 Bc5 {giuoco piano} *\")\n\nchess.get_comment()\n// -> \"giuoco piano\"\n\nchess.delete_comment()\n// -> \"giuoco piano\"\n\nchess.get_comment()\n// -> undefined\n```\n\n### .delete_comments()\n\nDelete and return comments for all positions.\n\n```js\nconst chess = new Chess()\n\nchess.load_pgn(\"1. e4 e5 {king's pawn opening} 2. Nf3 Nc6 3. Bc4 Bc5 {giuoco piano} *\")\n\nchess.delete_comments()\n// -> [\n//     {\n//       fen: \"rnbqkbnr/pppp1ppp/8/4p3/4P3/8/PPPP1PPP/RNBQKBNR w KQkq e6 0 2\",\n//       comment: \"king's pawn opening\"\n//     },\n//     {\n//       fen: \"r1bqkbnr/pppp1ppp/2n5/4p3/4P3/5N2/PPPP1PPP/RNBQKB1R w KQkq - 2 3\",\n//       comment: \"giuoco piano\"\n//     }\n//    ]\n\nchess.get_comments()\n// -> []\n```\n### .fen()\n\nReturns the FEN string for the current position.\n\n```js\nconst chess = new Chess()\n\n// make some moves\nchess.move('e4')\nchess.move('e5')\nchess.move('f4')\n\nchess.fen()\n// -> 'rnbqkbnr/pppp1ppp/8/4p3/4PP2/8/PPPP2PP/RNBQKBNR b KQkq f3 0 2'\n```\n\n### .game_over()\n\nReturns true if the game has ended via checkmate, stalemate, draw, threefold repetition, or insufficient material. Otherwise, returns false.\n\n```js\nconst chess = new Chess()\nchess.game_over()\n// -> false\n\n// stalemate\nchess.load('4k3/4P3/4K3/8/8/8/8/8 b - - 0 78')\nchess.game_over()\n// -> true\n\n// checkmate\nchess.load('rnb1kbnr/pppp1ppp/8/4p3/5PPq/8/PPPPP2P/RNBQKBNR w KQkq - 1 3')\nchess.game_over()\n// -> true\n```\n\n### .get(square)\n\nReturns the piece on the square:\n\n```js\nchess.clear()\nchess.put({ type: chess.PAWN, color: chess.BLACK }, 'a5') // put a black pawn on a5\n\nchess.get('a5')\n// -> { type: 'p', color: 'b' },\nchess.get('a6')\n// -> null\n```\n\n### .get_comment()\n\nRetrieve the comment for the current position, if it exists.\n\n```js\nconst chess = new Chess()\n\nchess.load_pgn(\"1. e4 e5 2. Nf3 Nc6 3. Bc4 Bc5 {giuoco piano} *\")\n\nchess.get_comment()\n// -> \"giuoco piano\"\n```\n\n### .get_comments()\n\nRetrieve comments for all positions.\n\n```js\nconst chess = new Chess()\n\nchess.load_pgn(\"1. e4 e5 {king's pawn opening} 2. Nf3 Nc6 3. Bc4 Bc5 {giuoco piano} *\")\n\nchess.get_comments()\n// -> [\n//     {\n//       fen: \"rnbqkbnr/pppp1ppp/8/4p3/4P3/8/PPPP1PPP/RNBQKBNR w KQkq e6 0 2\",\n//       comment: \"king's pawn opening\"\n//     },\n//     {\n//       fen: \"r1bqkbnr/pppp1ppp/2n5/4p3/4P3/5N2/PPPP1PPP/RNBQKB1R w KQkq - 2 3\",\n//       comment: \"giuoco piano\"\n//     }\n//    ]\n```\n\n### .header()\n\nAllows header information to be added to PGN output. Any number of key/value\npairs can be passed to .header().\n\n```js\nchess.header('White', 'Robert James Fischer')\nchess.header('Black', 'Mikhail Tal')\n\n// or\n\nchess.header('White', 'Morphy', 'Black', 'Anderssen', 'Date', '1858-??-??')\n```\n\nCalling .header() without any arguments returns the header information as an object.\n\n```js\nchess.header()\n// -> { White: 'Morphy', Black: 'Anderssen', Date: '1858-??-??' }\n```\n\n### .history([ options ])\n\nReturns a list containing the moves of the current game. Options is an optional\nparameter which may contain a 'verbose' flag. See .moves() for a description of the\nverbose move fields.\n\n```js\nconst chess = new Chess()\nchess.move('e4')\nchess.move('e5')\nchess.move('f4')\nchess.move('exf4')\n\nchess.history()\n// -> ['e4', 'e5', 'f4', 'exf4']\n\nchess.history({ verbose: true })\n// -> [{ color: 'w', from: 'e2', to: 'e4', flags: 'b', piece: 'p', san: 'e4' },\n//     { color: 'b', from: 'e7', to: 'e5', flags: 'b', piece: 'p', san: 'e5' },\n//     { color: 'w', from: 'f2', to: 'f4', flags: 'b', piece: 'p', san: 'f4' },\n//     { color: 'b', from: 'e5', to: 'f4', flags: 'c', piece: 'p', captured: 'p', san: 'exf4' }]\n```\n\n### .in_check()\n\nReturns true or false if the side to move is in check.\n\n```js\nconst chess = new Chess(\n    'rnb1kbnr/pppp1ppp/8/4p3/5PPq/8/PPPPP2P/RNBQKBNR w KQkq - 1 3'\n)\nchess.in_check()\n// -> true\n```\n\n### .in_checkmate()\n\nReturns true or false if the side to move has been checkmated.\n\n```js\nconst chess = new Chess(\n    'rnb1kbnr/pppp1ppp/8/4p3/5PPq/8/PPPPP2P/RNBQKBNR w KQkq - 1 3'\n)\nchess.in_checkmate()\n// -> true\n```\n\n### .in_draw()\n\nReturns true or false if the game is drawn (50-move rule or insufficient material).\n\n```js\nconst chess = new Chess('4k3/4P3/4K3/8/8/8/8/8 b - - 0 78')\nchess.in_draw()\n// -> true\n```\n\n### .in_stalemate()\n\nReturns true or false if the side to move has been stalemated.\n\n```js\nconst chess = new Chess('4k3/4P3/4K3/8/8/8/8/8 b - - 0 78')\nchess.in_stalemate()\n// -> true\n```\n\n### .in_threefold_repetition()\n\nReturns true or false if the current board position has occurred three or more\ntimes.\n\n```js\nconst chess = new Chess('rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1')\n// -> true\n// rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq occurs 1st time\nchess.in_threefold_repetition()\n// -> false\n\nchess.move('Nf3') chess.move('Nf6') chess.move('Ng1') chess.move('Ng8')\n// rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq occurs 2nd time\nchess.in_threefold_repetition()\n// -> false\n\nchess.move('Nf3') chess.move('Nf6') chess.move('Ng1') chess.move('Ng8')\n// rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq occurs 3rd time\nchess.in_threefold_repetition()\n// -> true\n```\n\n### .insufficient_material()\n\nReturns true if the game is drawn due to insufficient material (K vs. K,\nK vs. KB, or K vs. KN) otherwise false.\n\n```js\nconst chess = new Chess('k7/8/n7/8/8/8/8/7K b - - 0 1')\nchess.insufficient_material()\n// -> true\n```\n\n### .load(fen)\n\nThe board is cleared, and the FEN string is loaded. Returns true if the position was\nsuccessfully loaded, otherwise false.\n\n```js\nconst chess = new Chess()\nchess.load('4r3/8/2p2PPk/1p6/pP2p1R1/P1B5/2P2K2/3r4 w - - 1 45')\n// -> true\n\nchess.load('4r3/8/X12XPk/1p6/pP2p1R1/P1B5/2P2K2/3r4 w - - 1 45')\n// -> false, bad piece X\n```\n\n### .load_pgn(pgn, [ options ])\n\nLoad the moves of a game stored in\n[Portable Game Notation](http://en.wikipedia.org/wiki/Portable_Game_Notation).\n`pgn` should be a string. Options is an optional `object` which may contain\na string `newline_char` and a boolean `sloppy`.\n\nThe `newline_char` is a string representation of a valid RegExp fragment and is\nused to process the PGN. It defaults to `\\r?\\n`. Special characters\nshould not be pre-escaped, but any literal special characters should be escaped\nas is normal for a RegExp. Keep in mind that backslashes in JavaScript strings\nmust themselves be escaped (see `sloppy_pgn` example below). Avoid using\na `newline_char` that may occur elsewhere in a PGN, such as `.` or `x`, as this\nwill result in unexpected behavior.\n\nThe `sloppy` flag is a boolean that permits chess.js to parse moves in\nnon-standard notations. See `.move` documentation for more information about\nnon-SAN notations.\n\nThe method will return `true` if the PGN was parsed successfully, otherwise `false`.\n\n```js\nconst chess = new Chess()\nconst pgn = [\n    '[Event \"Casual Game\"]',\n    '[Site \"Berlin GER\"]',\n    '[Date \"1852.??.??\"]',\n    '[EventDate \"?\"]',\n    '[Round \"?\"]',\n    '[Result \"1-0\"]',\n    '[White \"Adolf Anderssen\"]',\n    '[Black \"Jean Dufresne\"]',\n    '[ECO \"C52\"]',\n    '[WhiteElo \"?\"]',\n    '[BlackElo \"?\"]',\n    '[PlyCount \"47\"]',\n    '',\n    '1.e4 e5 2.Nf3 Nc6 3.Bc4 Bc5 4.b4 Bxb4 5.c3 Ba5 6.d4 exd4 7.O-O',\n    'd3 8.Qb3 Qf6 9.e5 Qg6 10.Re1 Nge7 11.Ba3 b5 12.Qxb5 Rb8 13.Qa4',\n    'Bb6 14.Nbd2 Bb7 15.Ne4 Qf5 16.Bxd3 Qh5 17.Nf6+ gxf6 18.exf6',\n    'Rg8 19.Rad1 Qxf3 20.Rxe7+ Nxe7 21.Qxd7+ Kxd7 22.Bf5+ Ke8',\n    '23.Bd7+ Kf8 24.Bxe7# 1-0'\n]\n\nchess.load_pgn(pgn.join('\\n'))\n// -> true\n\nchess.fen()\n// -> 1r3kr1/pbpBBp1p/1b3P2/8/8/2P2q2/P4PPP/3R2K1 b - - 0 24\n\nchess.ascii()\n// -> '  +------------------------+\n//     8 | .  r  .  .  .  k  r  . |\n//     7 | p  b  p  B  B  p  .  p |\n//     6 | .  b  .  .  .  P  .  . |\n//     5 | .  .  .  .  .  .  .  . |\n//     4 | .  .  .  .  .  .  .  . |\n//     3 | .  .  P  .  .  q  .  . |\n//     2 | P  .  .  .  .  P  P  P |\n//     1 | .  .  .  R  .  .  K  . |\n//       +------------------------+\n//         a  b  c  d  e  f  g  h'\n\n// Parse non-standard move formats and unusual line separators\nconst sloppy_pgn = [\n    '[Event \"Wijk aan Zee (Netherlands)\"]',\n    '[Date \"1971.01.26\"]',\n    '[Result \"1-0\"]',\n    '[White \"Tigran Vartanovich Petrosian\"]',\n    '[Black \"Hans Ree\"]',\n    '[ECO \"A29\"]',\n    '',\n    '1. Pc2c4 Pe7e5', // non-standard\n    '2. Nc3 Nf6',\n    '3. Nf3 Nc6',\n    '4. g2g3 Bb4', // non-standard\n    '5. Nd5 Nxd5',\n    '6. c4xd5 e5-e4', // non-standard\n    '7. dxc6 exf3',\n    '8. Qb3 1-0'\n].join('|')\n\nconst options = {\n    newline_char: '\\\\|', // Literal '|' character escaped\n    sloppy: true\n}\n\nchess.load_pgn(sloppy_pgn)\n// -> false\n\nchess.load_pgn(sloppy_pgn, options)\n// -> true\n\nchess.fen()\n// -> 'r1bqk2r/pppp1ppp/2P5/8/1b6/1Q3pP1/PP1PPP1P/R1B1KB1R b KQkq - 1 8'\n```\n\n### .move(move, [ options ])\n\nAttempts to make a move on the board, returning a move object if the move was\nlegal, otherwise null. The .move function can be called two ways, by passing\na string in Standard Algebraic Notation (SAN):\n\n```js\nconst chess = new Chess()\n\nchess.move('e4')\n// -> { color: 'w', from: 'e2', to: 'e4', flags: 'b', piece: 'p', san: 'e4' }\n\nchess.move('nf6') // SAN is case sensitive!!\n// -> null\n\nchess.move('Nf6')\n// -> { color: 'b', from: 'g8', to: 'f6', flags: 'n', piece: 'n', san: 'Nf6' }\n```\n\nOr by passing .move() a move object (only the 'to', 'from', and when necessary\n'promotion', fields are needed):\n\n```js\nconst chess = new Chess()\n\nchess.move({ from: 'g2', to: 'g3' })\n// -> { color: 'w', from: 'g2', to: 'g3', flags: 'n', piece: 'p', san: 'g3' }\n```\n\nAn optional sloppy flag can be used to parse a variety of non-standard move\nnotations:\n\n```js\nconst chess = new Chess()\n\n// various forms of Long Algebraic Notation\nchess.move('e2e4', { sloppy: true })\n// -> { color: 'w', from: 'e2', to: 'e4', flags: 'b', piece: 'p', san: 'e4' }\nchess.move('e7-e5', { sloppy: true })\n// -> { color: 'b', from: 'e7', to: 'e5', flags: 'b', piece: 'p', san: 'e5' }\nchess.move('Pf2f4', { sloppy: true })\n// -> { color: 'w', from: 'f2', to: 'f4', flags: 'b', piece: 'p', san: 'f4' }\nchess.move('Pe5xf4', { sloppy: true })\n// -> { color: 'b', from: 'e5', to: 'f4', flags: 'c', piece: 'p', captured: 'p', san: 'exf4' }\n\n// correctly parses incorrectly disambiguated moves\nchess = new Chess(\n    'r2qkbnr/ppp2ppp/2n5/1B2pQ2/4P3/8/PPP2PPP/RNB1K2R b KQkq - 3 7'\n)\n\nchess.move('Nge7') // Ne7 is unambiguous because the knight on c6 is pinned\n// -> null\n\nchess.move('Nge7', { sloppy: true })\n// -> { color: 'b', from: 'g8', to: 'e7', flags: 'n', piece: 'n', san: 'Ne7' }\n```\n\n### .moves([ options ])\n\nReturns a list of legal moves from the current position. The function takes an optional parameter which controls the single-square move generation and verbosity.\n\n```js\nconst chess = new Chess()\nchess.moves()\n// -> ['a3', 'a4', 'b3', 'b4', 'c3', 'c4', 'd3', 'd4', 'e3', 'e4',\n//     'f3', 'f4', 'g3', 'g4', 'h3', 'h4', 'Na3', 'Nc3', 'Nf3', 'Nh3']\n\nchess.moves({ square: 'e2' })\n// -> ['e3', 'e4']\n\nchess.moves({ square: 'e9' }) // invalid square\n// -> []\n\nchess.moves({ verbose: true })\n// -> [{ color: 'w', from: 'a2', to: 'a3',\n//       flags: 'n', piece: 'p', san 'a3'\n//       # a captured: key is included when the move is a capture\n//       # a promotion: key is included when the move is a promotion\n//     },\n//     ...\n//     ]\n```\n\nThe _piece_, _captured_, and _promotion_ fields contain the lowercase\nrepresentation of the applicable piece.\n\nThe _flags_ field in verbose mode may contain one or more of the following values:\n\n-   'n' - a non-capture\n-   'b' - a pawn push of two squares\n-   'e' - an en passant capture\n-   'c' - a standard capture\n-   'p' - a promotion\n-   'k' - kingside castling\n-   'q' - queenside castling\n\nA flag of 'pc' would mean that a pawn captured a piece on the 8th rank and promoted.\n\n### .pgn([ options ])\n\nReturns the game in PGN format. Options is an optional parameter which may include\nmax width and/or a newline character settings.\n\n```js\nconst chess = new Chess()\nchess.header('White', 'Plunky', 'Black', 'Plinkie')\nchess.move('e4')\nchess.move('e5')\nchess.move('Nc3')\nchess.move('Nc6')\n\nchess.pgn({ max_width: 5, newline_char: '<br />' })\n// -> '[White \"Plunky\"]<br />[Black \"Plinkie\"]<br /><br />1. e4 e5<br />2. Nc3 Nc6'\n```\n\n### .put(piece, square)\n\nPlace a piece on the square where piece is an object with the form\n{ type: ..., color: ... }. Returns true if the piece was successfully placed,\notherwise, the board remains unchanged and false is returned. `put()` will fail\nwhen passed an invalid piece or square, or when two or more kings of the\nsame color are placed.\n\n```js\nchess.clear()\n\nchess.put({ type: chess.PAWN, color: chess.BLACK }, 'a5') // put a black pawn on a5\n// -> true\nchess.put({ type: 'k', color: 'w' }, 'h1') // shorthand\n// -> true\n\nchess.fen()\n// -> '8/8/8/p7/8/8/8/7K w - - 0 0'\n\nchess.put({ type: 'z', color: 'w' }, 'a1') // invalid piece\n// -> false\n\nchess.clear()\n\nchess.put({ type: 'k', color: 'w' }, 'a1')\n// -> true\n\nchess.put({ type: 'k', color: 'w' }, 'h1') // fail - two kings\n// -> false\n```\n\n### .remove(square)\n\nRemove and return the piece on _square_.\n\n```js\nchess.clear()\nchess.put({ type: chess.PAWN, color: chess.BLACK }, 'a5') // put a black pawn on a5\nchess.put({ type: chess.KING, color: chess.WHITE }, 'h1') // put a white king on h1\n\nchess.remove('a5')\n// -> { type: 'p', color: 'b' },\nchess.remove('h1')\n// -> { type: 'k', color: 'w' },\nchess.remove('e1')\n// -> null\n```\n\n### .reset()\n\nReset the board to the initial starting position.\n\n### .set_comment(comment)\n\nComment on the current position.\n\n```js\nconst chess = new Chess()\n\nchess.move(\"e4\")\nchess.set_comment(\"king's pawn opening\")\n\nchess.pgn()\n// -> \"1. e4 {king's pawn opening}\"\n```\n\n### .square_color(square)\n\nReturns the color of the square ('light' or 'dark').\n\n```js\nconst chess = Chess()\nchess.square_color('h1')\n// -> 'light'\nchess.square_color('a7')\n// -> 'dark'\nchess.square_color('bogus square')\n// -> null\n```\n\n### .turn()\n\nReturns the current side to move.\n\n```js\nchess.load('rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1')\nchess.turn()\n// -> 'b'\n```\n\n### .undo()\n\nTakeback the last half-move, returning a move object if successful, otherwise null.\n\n```js\nconst chess = new Chess()\n\nchess.fen()\n// -> 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1'\nchess.move('e4')\nchess.fen()\n// -> 'rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1'\n\nchess.undo()\n// -> { color: 'w', from: 'e2', to: 'e4', flags: 'b', piece: 'p', san: 'e4' }\nchess.fen()\n// -> 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1'\nchess.undo()\n// -> null\n```\n\n### .validate_fen(fen):\n\nReturns a validation object specifying validity or the errors found within the\nFEN string.\n\n```js\nchess.validate_fen('2n1r3/p1k2pp1/B1p3b1/P7/5bP1/2N1B3/1P2KP2/2R5 b - - 4 25')\n// -> { valid: true, error_number: 0, error: 'No errors.' }\n\nchess.validate_fen('4r3/8/X12XPk/1p6/pP2p1R1/P1B5/2P2K2/3r4 w - - 1 45')\n// -> { valid: false, error_number: 9,\n//     error: '1st field (piece positions) is invalid [invalid piece].' }\n```\n\n## MUSIC\n\nMusical support provided by:\n\n-   [The Grateful Dead](https://www.youtube.com/watch?v=z-D9rdJWfWs)\n-   [Umphrey's McGee](https://www.youtube.com/watch?v=auEfZVcYp64)\n\n## BUGS\n\n-   The en passant square and castling flags aren't adjusted when using the put/remove functions (workaround: use .load() instead)\n","readmeFilename":"README.md"}