Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/niklasf/chessops
Chess and chess variant rules and operations in TypeScript
https://github.com/niklasf/chessops
chess fen lichess typescript
Last synced: about 4 hours ago
JSON representation
Chess and chess variant rules and operations in TypeScript
- Host: GitHub
- URL: https://github.com/niklasf/chessops
- Owner: niklasf
- License: gpl-3.0
- Created: 2019-08-17T15:34:24.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-12-14T11:08:08.000Z (8 days ago)
- Last Synced: 2024-12-15T07:02:36.256Z (7 days ago)
- Topics: chess, fen, lichess, typescript
- Language: TypeScript
- Homepage: https://niklasf.github.io/chessops/
- Size: 1.66 MB
- Stars: 122
- Watchers: 8
- Forks: 38
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE.txt
Awesome Lists containing this project
README
# chessops
[![Test](https://github.com/niklasf/chessops/workflows/Test/badge.svg)](https://github.com/niklasf/chessops/actions)
[![npm](https://img.shields.io/npm/v/chessops)](https://www.npmjs.com/package/chessops)Chess and chess variant rules and operations in TypeScript.
## Documentation
[View TypeDoc](https://niklasf.github.io/chessops/)
## Features
- [Read and write FEN](https://niklasf.github.io/chessops/modules/fen.html)
- Vocabulary
- `Square`
- `SquareSet` (implemented as bitboards)
- `Color`
- `Role` (piece type)
- `Piece` (`Role` and `Color`)
- `Board` (map of piece positions)
- `Castles`
- `Setup` (a not necessarily legal position)
- `Position` (base class for legal positions, `Chess` is a concrete implementation)
- [Variant rules](https://niklasf.github.io/chessops/modules/variant.html):
Standard chess, Crazyhouse, King of the Hill, Three-check,
Antichess, Atomic, Horde, Racing Kings
- Move making
- Legal move and drop move generation
- Game end and outcome
- Insufficient material
- Setup validation
- Supports Chess960
- [Attacks and rays](https://niklasf.github.io/chessops/modules/attacks.html)
using Hyperbola Quintessence (faster to initialize than Magic Bitboards)
- Read and write UCI move notation
- [Read and write SAN](https://niklasf.github.io/chessops/modules/san.html)
- [Read and write PGN](https://niklasf.github.io/chessops/modules/pgn.html)
- Parser supports asynchronous streaming
- Game tree model
- Transform game tree to augment nodes with arbitrary user data
- Parse comments with evaluations, clocks and shapes
- [Transformations](https://niklasf.github.io/chessops/modules/transform.html): Mirroring and rotating
- [Compatibility](https://niklasf.github.io/chessops/modules/compat.html):
[chessground](https://github.com/ornicar/chessground) and
[scalachess](https://github.com/ornicar/scalachess)## Example
```javascript
import { Chess } from 'chessops/chess';
import { parseFen } from 'chessops/fen';const setup = parseFen('r1bqkbnr/ppp2Qpp/2np4/4p3/2B1P3/8/PPPP1PPP/RNB1K1NR b KQkq - 0 4').unwrap();
const pos = Chess.fromSetup(setup).unwrap();
console.assert(pos.isCheckmate());
```## License
chessops is licensed under the GNU General Public License 3 or any later
version at your choice. See LICENSE.txt for details.