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

@samcjparry/ts-chess

v1.0.2

Published

## Introduction

Downloads

2

Readme

TypeScript Chess Engine

Introduction

  • Hello! Welcome to my chess engine. This was my exploration into object orientated programming using TypeScript.
  • When creating this project, I tried to stick to SOLID principles as much as possible, but this was my first time so go easy on me.

How To Use

  • You can add the package as a dependency using npm:
npm install @samcjparry/ts-chess
  • Or using yarn:
yarn add @samcjparry/ts-chess
  • Then first of all, you'll need to create a new Game:
import { Game } from "@samcjparry/ts-chess";

const game = new Game();
  • If you want to create a new game with custom pieces, you will have to create an array with the pieces you want and pass it as an argument when you create the game:
  • ACHTUNG MINEFIELD - The colours 'White' and 'Black' are represented by the numbers 0 and 1 respectively. This is because I wanted to use an enum. I'm aware that if something is one of two things it should be a boolean but this is my engine so sue me.
const pieces = [
  { piece: "Kg4", colour: 0 },
  { piece: "Nd3", colour: 1 },
  { piece: "d4", colour: 1 },
];

const game = new Game(pieces);

// Will spawn a white king on square g4, a black knight on square d3, and a black pawn on square d4
  • Also worthy of note is that I use standard chess notation as much as possible, so...

    • Named pieces are notated thus:
      • K - King
      • Q - Queen
      • R - Rook
      • N - Knight
      • B - Bishop
    • Pawns aren't notated, so if you just pass in a square it will generate a pawn in that square.

Moving a piece

  • The current colour's move can be found by running:
import { isWhiteMove } from "ChessGame";

console.log(isWhiteMove); // logs true/false

The game will alternate the current colour at the end of the turn. This IS a boolean.