A Rust / TypeScript library for Gliński's hexagonal chess, and the brain of hexchess.club
Execute hexchess
to open the following command line interface. More documentation to come.
Usage: hexchess <COMMAND>
Commands:
apply Apply notation to game
get Get piece value at position
parse Parse hexchess to JSON
targets List target moves from a position
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
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.
Create a new Hexchess
object after applying a piece of Notation
.
import { applyNotation } from '@bedard/hexchess'
applyNotation(hexchess, notation)
// { board: { ... }, enPassant, turn, fullmove, halfmove }
Create an empty Hexchess
object.
import { createHexchess } from '@bedard/hexchess'
createHexchess()
// { board: { ... }, enPassant, turn, fullmove, halfmove }
Create a Hexchess
object with the initial game state.
import { createHexchessInitial } from '@bedard/hexchess'
createHexchessInitial()
// { board: { ... }, enPassant, turn, fullmove, halfmove }
Find all legal moves from a position and return the resulting array of Notation
objects.
import { getTargets } from '@bedard/hexchess'
targets(hexchess, 'g4')
// [{ from, to, promotion }, ...]
Create a Hexchess
object from it's string representation.
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 }
Create a Notation
object from it's string representation.
import { parseNotation } from '@bedard/hexchess'
parseNotation('e4e5')
// { from: 'e4', to: 'e5', promotion: null }
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'
Copyright (c) 2024-present, Scott Bedard