chess-ai
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

ChessAI

A simple TypeScript ChessAI package to add intelligence to chess.js based Chess games.

This package is part of one of my online courses available here

You can play the game here.

How to

  • install
npm i chess-ai
pnpm add chess-ai

or

yarn add chess-ai
  • import
import { calculateBestMove, initGame } from "chess-ai";
  • use
/**
 * (optional)
 * @param chess ChessInstance created using new Chess() /chess.js/
 * @param difficulty number usually between 0 and 2 inclusive, higher difficulty will increase computaion time
 */
initGame(chess, difficulty)
// if initGame() was called before
const bestMove = calculateBestMove();

// if initGame not called before, you must pass the chess and difficulty params when you call this fucniton for the first time.
const chess = new Chess();
...
...
const bestMove = calculateBestMove(chess, 1); // difficulty = 1

if(bestMove) chess.move(bestMove);

Package Sidebar

Install

npm i chess-ai

Weekly Downloads

3

Version

0.0.2

License

MIT

Unpacked Size

9.51 kB

Total Files

4

Last publish

Collaborators

  • mayank1513