npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bchess

v1.0.8

Published

Yet another chess engine.

Downloads

38

Readme

bchess

Build Status License Codacy Badge Codecov Badge jsDelivr badge Heroku Badge

A chess engine written in modern javascript with a minimal codebase.

Getting Started

Node

npm i bchess

CDN

<script src="https://cdn.jsdelivr.net/npm/bchess@1/dist/bchess.min.js"></script>

Usage

Simply include the library to start using it:

const { Chess, Action, Piece } = require("bchess");
const chess = new Chess({color: "white"});

You can also initialise a new game using FEN notation:

const chess = new Chess({fen:"kb5Q/p7/Pp6/1P6/4p3/4R3/4P1p1/6K1"});

API

move

Carry out the specified move

chess.move({from:"c2",to:"c4"});

A third option is available to specify the piece used for promotion (if available):

chess.move({from:"c2",to:"c4",promote:"Q"});

Returns

One or more Action flags.

The following is a list of possible flags:

  • MOVE
  • PLAYER_CAPTURE
  • OPPONENT_CAPTURE
  • CASTLE_KING
  • CASTLE_QUEEN
  • EN_PASSANT
  • PROMOTE
  • INVALID_ACTION

set

Set a piece down anywhere on the board:

chess.set({square: "h4", piece: new Piece("Q","white")});

available

Return an array of available moves a piece can make

chess.available({square:"e2"})

history

Get the current game history

chess.history

ascii

Returns an ascii string representing the current board

chess.ascii()

Example output:

  +--------------------------+
8 |  r  n  b  q  k  b  n  r  |
7 |  p  p  p  p  p  .  p  p  |
6 |  .  .  .  .  .  P  .  .  |
5 |  .  .  .  .  .  .  .  .  |
4 |  .  .  .  .  .  .  .  .  |
3 |  .  .  .  .  .  N  .  B  |
2 |  P  P  P  P  P  P  .  P  |
1 |  R  N  B  Q  .  R  K  .  |
  +--------------------------+
     a  b  c  d  e  f  g  h

The perspective of the board returned depends on the Chess myColor property.

Options

|Property|Description|Values|Default| |--|--|--|--| |border|Toggle border display|true / false|true| |file|Toggle file display|true / false|true| |rank|Toggle rank display|true / false|true| |unicode|Display unicode characters for pieces instead of FEN notation|true/ false|false|

score

Get the current game score

chess.score()

get

Fetch the information at a current square

chess.get({square:"g8"})

fen

Returns the current game state in FEN notation.

chess.fen()

Example output:

rnbqkbnr/ppppp1pp/5P2/1Q6/8/5N1B/PPPPPP1P/RNBQ1RK1

moves

Return the total move count (completed turns)

chess.moves

undo

Undo the most recent move

chess.undo();

turn

Whose turn is it?

chess.turn()

check

Returns pieces in check (and pieces checking them)

chess.check()

checkmate

Returns checkmate status for both sides

chess.checkmate()

stalemate

Returns stalemate status for both sides

chess.stalemate()

moveToSAN

Return the SAN notation of a move

chess.moveToSAN({from:"f2",to:"f4"})