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

@bedard/hexchess

v0.10.0

Published

A Rust / TypeScript library for Gliński's hexagonal chess, and the brain of hexchess.club

Downloads

157

Readme

hexchess.rs

Build Coverage NPM Crates.io License

A Rust / TypeScript library for Gliński's hexagonal chess, and the brain of hexchess.club

Basic usage

Execute hexchess to open the following command line interface.

Usage: hexchess <COMMAND>

Commands:
  apply        Apply sequence of moves to a position
  get-status   Get game status (w, b, stalemate, checkmate)
  get-targets  Get legal moves
  parse        Parse hexchess fen to JSON
  test-move    Test if a move is legal
  help         Print this message or the help of the given subcommand(s)

Options:
  -h, --help     Print help
  -V, --version  Print version

TypeScript

A collection of wasm bindings available via @bedard/hexchess, listed below are the available methods.

Note: Depending on the bundler, plugins may be required for Web Assembly and top-level await.

applyNotation

Create a new Hexchess object and apply a single Notation.

import { applyNotation } from '@bedard/hexchess'

applyNotation(hexchess, notation)

// { board: { ... }, enPassant, turn, fullmove, halfmove }

applySequence

Create a new Hexchess object and apply a whitespace-separated sequence of moves. An error is thrown if a piece of notation is not valid or a move is illegal.

import { applySequence } from '@bedard/hexchess'

applySequence(hexchess, 'g4g5 e7e6')

// { board: { ... }, enPassant, turn, fullmove, halfmove }

createHexchess

Create an empty Hexchess object.

import { createHexchess } from '@bedard/hexchess'

createHexchess()

// { board: { ... }, enPassant, turn, fullmove, halfmove }

createHexchessInitial

Create a Hexchess object with the initial game state.

import { createHexchessInitial } from '@bedard/hexchess'

createHexchessInitial()

// { board: { ... }, enPassant, turn, fullmove, halfmove }

findKing

Find a player's king.

import { findKing } from '@bedard/hexchess'

findKing(hexchess, 'b')

getColor

Get the color of a piece.

import { getColor } from '@bedard/hexchess'

getColor('p') // 'b'
getColor('P') // 'w'
getColor('?') // null

getPositionColor

Get color of a piece by board position. If no piece is present, null will be returned.

import { getPositionColor } from '@bedard/hexchess'

getPositionColor(hexchess, 'f5') // 'w'

getTargets

Find all legal moves from a position and return an array of Notation objects.

import { getTargets } from '@bedard/hexchess'

targets(hexchess, 'g4')

// [{ from, to, promotion }, ...]

isCheckmate

Test if the board is in checkmate.

import { isCheckmate } from '@bedard/hexchess'

isCheckmate(hexchess) // true / false

isThreatened

Test if a position is threatened.

import { isThreatened } from '@bedard/hexchess'

isThreatened(hexchess, 'g10') // false

parseHexchess

Create a Hexchess object from it's string representation. If hexchess is invalid, undefined will be returned.

import { parseHexchess } from '@bedard/hexchess'

parseHexchess('b/qbk/n1b1n/r5r/ppppppppp/11/5P5/4P1P4/3P1B1P3/2P2B2P2/1PRNQBKNRP1 w - 0 1')

// { board: { ... }, enPassant, turn, fullmove, halfmove }

parseNotation

Create a Notation object from it's string representation. If notation is invalid, undefined will be returned.

import { parseNotation } from '@bedard/hexchess'

parseNotation('e4e5')

// { from: 'e4', to: 'e5', promotion: null }

stringifyHexchess

Convert a Hexchess object to it's string representation.

import { stringifyHexchess } from '@bedard/hexchess'

stringifyHexchess(hexchess)

// 'b/qbk/n1b1n/r5r/ppppppppp/11/5P5/4P1P4/3P1B1P3/2P2B2P2/1PRNQBKNRP1 w - 0 1'

License

MIT

Copyright (c) 2024-present, Scott Bedard