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

chess-ai-kong

v0.3.3

Published

Chess AI based on Alpha-Beta pruning algorithm.

Downloads

4

Readme

ChessCorp Artificial Intelligence: Kong

Abstract

This project is an example of an Artificial Intelligence module.

It uses the following modules from ChessCorp project:

  • Chess Rules set View

Engine

The AI search engine is based on the [Alpha Beta Pruning algorithm] (https://en.wikipedia.org/wiki/Alpha%E2%80%93beta_pruning). It chooses best move by simulating in-depth plies and refuting moves that cannot alter its final decision.

Strategies

The AI implements several strategies that can be configured as an option. Strategies are based on material and positions. They influence the board evaluation and as a matter of fact the AI's way of playing.

Basic Strategy

The basic strategy is based on the common principles about chess programming.

-Pawns progress forward. -Bishops and Knights control center, avoid corners and extreme corners. -Queen and Rook avoid center. -King hide in the back.

Random Strategy

The random strategy does not take into account material and position. Losing a pawn is as bad as losing a queen.

Configuration

The AI can be configured be setting options:

  • depth: The depth of the search algorithm. A higher depth provide a deeper and longer thinking from the AI (Integer, 3 by default).
  • monitor: Enable/disable the monitoring. Monitoring might be time-consuming because it generates PGN test and stores searched nodes. (Boolean, false by default).
  • strategy: Set the strategy to use to evaluate board and moves (String, 'basic' by default).
  • timeout: Set up a timeout after which the AI shall return a move (Integer, 10000 by default).

Install

As a Node module

$ npm install chess-ai-kong

This will install chess-ai-kong module in the node_modules folder.

Usage

Import the main ai-kong object

> var chessAI = require('chess-ai-kong');

> chessAI
{ 
  playPosition: [Function: playPosition],
  play: [Function: play],
  setOptions: [Function: setOptions]
}

Configure

 > chessAI.setOptions(
{
  depth: 4,
  monitor: true,
  strategy: 'basic',
  timeout: 10000
}
);

Play after a sequence of moves

The AI starts from an initial position and replays every moves provided before searching for the next move. The method returns a PGN move. PGN move text is described here https://en.wikipedia.org/wiki/Portable_Game_Notation

> var move = chessAi.play(['e4']);
'Nf6'

Note: The AI search a move for the player's turn after the sequence of moves. If there is an odd number of moves, the AI searches for a WHITE move, otherwise, it searches for a BLACK move.

Play after a certain position

The AI starts from the given position and search for the next move. The method returns a PGN move. PGN move text is described here https://en.wikipedia.org/wiki/Portable_Game_Notation

> var move = chessAi.playPosition(position);
'e4'

Note: The AI search a move for the player's turn. For example, if the initial position is passed in parameter, the AI will search for a WHITE move.