All Projects → yo35 → kokopu

yo35 / kokopu

Licence: LGPL-3.0 license
A JavaScript/TypeScript library implementing the chess game rules and providing tools to read/write the standard chess file formats.

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
CSS
56736 projects

Projects that are alternatives of or similar to kokopu

php-chess
A chess library for PHP.
Stars: ✭ 42 (+133.33%)
Mutual labels:  chess, pgn, fen
uci
A thin wrapper on a uci chess engine
Stars: ✭ 33 (+83.33%)
Mutual labels:  chess, uci
chess
An R package to read, write, create and explore chess games
Stars: ✭ 60 (+233.33%)
Mutual labels:  chess, pgn
ChessLib
C# chess library containing a complete data structure and move generation.
Stars: ✭ 37 (+105.56%)
Mutual labels:  chess, fen
chesslib
chess library for legal move generation, FEN/PGN parsing and more
Stars: ✭ 151 (+738.89%)
Mutual labels:  pgn, fen
cm-pgn
Parse and create PGNs (Portable Game Notation for chess games)
Stars: ✭ 16 (-11.11%)
Mutual labels:  chess, pgn
jerry
Jerry - Chess Program
Stars: ✭ 79 (+338.89%)
Mutual labels:  chess, uci
Demolito
UCI Chess Engine
Stars: ✭ 41 (+127.78%)
Mutual labels:  chess, uci
eschecs
UCI chess GUI
Stars: ✭ 32 (+77.78%)
Mutual labels:  chess, uci
liPGN
This program uses the lichess REST API to retrieve all the games of a user and transform them into a big PGN file that you can then import into your favourite game analysis tool (ie. scid)
Stars: ✭ 14 (-22.22%)
Mutual labels:  chess, pgn
chessops
Chess and chess variant rules and operations in TypeScript
Stars: ✭ 66 (+266.67%)
Mutual labels:  chess, fen
chessalyzer.js
A JavaScript library for batch analyzing chess games
Stars: ✭ 14 (-22.22%)
Mutual labels:  chess, pgn
chess-puzzle-maker
Creates chess puzzles from chess games and positions
Stars: ✭ 34 (+88.89%)
Mutual labels:  chess, pgn
liground
A free, open-source and modern Chess Variant Analysis GUI for the 21st century
Stars: ✭ 41 (+127.78%)
Mutual labels:  chess, uci
rust-pgn-reader
Fast non-allocating and streaming reader for chess games in PGN notation
Stars: ✭ 46 (+155.56%)
Mutual labels:  chess, pgn
Chess.js
A Javascript chess library for chess move generation/validation, piece placement/movement, and check/checkmate/draw detection
Stars: ✭ 2,557 (+14105.56%)
Mutual labels:  chess
fastchess
Predicts the best chess move with 27.5% accuracy by a single matrix multiplication
Stars: ✭ 75 (+316.67%)
Mutual labels:  chess
Nibbler
Nibbler - Leela Chess Zero (Lc0) interface
Stars: ✭ 185 (+927.78%)
Mutual labels:  chess
Sunfish
Sunfish: a Python Chess Engine in 111 lines of code
Stars: ✭ 2,254 (+12422.22%)
Mutual labels:  chess
lila-openingexplorer
Opening explorer for lichess.org that can handle all the variants and billions of unique positions
Stars: ✭ 89 (+394.44%)
Mutual labels:  chess

Kokopu

Kokopu is a JavaScript/TypeScript library for chess applications. It implements the chess game rules, and provides tools to read/write the standard chess file formats (PGN, FEN, UCI, etc.).

https://www.npmjs.com/package/kokopu

Build Status Coverage Status

Download

https://kokopu.yo35.org/dist/kokopu.zip

Documentation

https://kokopu.yo35.org/

Migrate to 3.x and 4.x

Versions 3.0.0 and 4.0.0 introduce some breaking changes with regard to the previous versions. To determine whether your codebase needs to be adapted or not when upgrading Kokopu, please look at:

Features

  • Chess move generation.
  • Check, checkmate and stalemate detection.
  • Move legality check.
  • Algrebraic notation parsing and generation.
  • FEN notation parsing and generation.
  • UCI move parsing and generation.
  • PGN file parsing and generation (including advanced PGN features such as commentaries, sub-variations, NAGs, non-standard starting position...).
  • Support several chess variants:
    • Chess960, also known as Fischer Random Chess.
    • Antichess, also known as losing chess, giveaway chess, suicide chess...
    • Horde chess (following Lichess/Chess.com rules).

Kokopu is a headless library, meaning it does not provide any user interface. If you are interested in UI features (e.g. to be able to render a chessboard component within a web page), you may take a look at Kokopu-React, which is a React-based library built on top of Kokopu to provide these kind of features.

Example

const { Position } = require('kokopu');

// Create a new position, play some moves...
const position = new Position();
position.play('e4');
position.play('e5');
position.play('Nf3');

// Display an ASCII-art representation of the position.
console.log(position.ascii());

// +---+---+---+---+---+---+---+---+
// | r | n | b | q | k | b | n | r |
// +---+---+---+---+---+---+---+---+
// | p | p | p | p |   | p | p | p |
// +---+---+---+---+---+---+---+---+
// |   |   |   |   |   |   |   |   |
// +---+---+---+---+---+---+---+---+
// |   |   |   |   | p |   |   |   |
// +---+---+---+---+---+---+---+---+
// |   |   |   |   | P |   |   |   |
// +---+---+---+---+---+---+---+---+
// |   |   |   |   |   | N |   |   |
// +---+---+---+---+---+---+---+---+
// | P | P | P | P |   | P | P | P |
// +---+---+---+---+---+---+---+---+
// | R | N | B | Q | K | B |   | R |
// +---+---+---+---+---+---+---+---+
// b KQkq -

// List the available moves.
const moves = position.moves();
console.log(moves.map(move => position.notation(move)));

// [ 'a6', 'a5', 'b6', 'b5', 'c6', 'c5', 'd6','d5', 'f6', 'f5', 'g6',
// 'g5', 'h6', 'h5', 'Na6', 'Nc6', 'Qe7', 'Qf6', 'Qg5', 'Qh4', 'Ke7',
// 'Be7', 'Bd6', 'Bc5', 'Bb4', 'Ba3', 'Nf6', 'Nh6', 'Ne7' ]

More examples available in documentation.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].