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 🙏

© 2025 – Pkg Stats / Ryan Hefner

monkfish

v0.2.0

Published

A Chess Engine in Typescript

Downloads

52

Readme

Monkfish

a chess engine in typescript for Deno.

Demo: https://monkfish-demo.vercel.app/

Getting Starting

for Node

npm i monkfish

and then

import { Game } from 'monkfish'

const game = new Game()

game.move({ from : 'a2', to: 'a3' })

const aiMove = game.bestMove()
game.move(aiMove)

for Deno

import { Game } from 'https://deno.land/x/[email protected]/mod.ts'

const game = new Game()

API

.move(move: MoveObject): void

game.move({ from : 'a2', to: 'a3' }) // move piece on a2 to a3
game.move({ from : 'a7', to: 'a8', promotion: 'Q' }) // move piece on a7 to a8 and promote to queen

.undo(): void

undo the last move

const game = new Game()
game.move({ from : 'a2', to: 'a3' })
game.fen() // "rnbqkbnr/pppppppp/8/8/8/P7/1PPPPPPP/RNBQKBNR b KQkq - 1 1"
game.undo()
game.fen() // "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"

.sideToMove(): 'w' | 'b'

const game = new Game()
game.sideToMove() // 'w'

.load(fen: string): void

game.load('rnbqkbnr/pppppppp/8/8/3P4/8/PPP1PPPP/RNBQKBNR b KQkq - 1 1')

.isGameOver(): boolean

const game = new Game('r1bqkbnr/pppppQ2/2n3p1/7p/2B1P3/8/PPPP1PPP/RNB1K1NR b kq - 0 1')
game.isGameOver() // true
const game = new Game('r2qkb2/p1p2p2/2npbnpr/1p2p2p/2B1P2P/NPP2N1R/P2P1PP1/R1BQK3 b q - 50 30')
game.isGameOver() // true

.isInCheck(): boolean

const game = new Game('r1bqkbnr/pppppQ2/2n3p1/7p/2B1P3/8/PPPP1PPP/RNB1K1NR b kq - 0 1')
game.isInCheck() // true

.fen(): string

const game = new Game()
game.fen() // "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"

.status(): string

const game = new Game()
game.status() // "playing"
const game = new Game('r2qkb2/p1p2p2/2npbnpr/1p2p2p/2B1P2P/NPP2N1R/P2P1PP1/R1BQK3 b q - 50 30')
game.status() // "draw by fifty rule"
const game = new Game('r1bqkbnr/pppppQ2/2n3p1/7p/2B1P3/8/PPPP1PPP/RNB1K1NR b kq - 0 1')
game.status() // "white won by checkmate"

.claimDraw(): Boolean

claim draw once in a threefold repetition state.
will return true if in threefold repetition state and game will be set to draw, otherwise will return false.

// once in a threefold repetition state
game.claimDraw() // true
game.status() // "draw by threefold repetition"
game.isGameOver() // true

.pieceOnSquare(square: BoardPositionNotation): string | null

const game = new Game()
game.pieceOnSquare('a2') // "P"
game.pieceOnSquare('b8') // "n"
game.pieceOnSquare('b4') // null

.possibleMoves(): BoardPositionNotationMove[]

get all possible moves for the current side

const game = new Game()
game.possibleMove() // [{ from: "b1", to: "c3", promotion: null, piece: "N", castling: null },
  // { from: "b1", to: "a3", promotion: null, piece: "N", castling: null },
  // { from: "g1", to: "h3", promotion: null, piece: "N", castling: null },
  // { from: "g1", to: "f3", promotion: null, piece: "N", castling: null },
  // { from: "a2", to: "a3", promotion: null, piece: "P", castling: null },
  // ...]

.possibleMovesForPosition(position: BoardPositionNotation): BoardPositionNotationMove[]

et all possible moves for a certain square

const game = new Game()
game.possibleMovesForPosition('b1') // [{ from: "b1", to: "c3", promotion: null, piece: "N", castling: null }, { from: "b1", to: "a3", promotion: null, piece: "N", castling: null }]

.bestMove(depth: number = 5): BoardPositionNotationMove | null

try to get the best possible move given a depth to search in

const game = new Game()
game.bestMove('b1') // { from: "b1", to: "c3", promotion: null, piece: "N", castling: null }

TODO:

  • more tests
  • algebraic notation moves