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

aima-checkers-gui

v0.1.12

Published

Checkers browser game,made with aima.js and React.

Downloads

34

Readme

Checkers

NPM version Gitter

Screenshot

Usage

You can simply play this in the browser: davidpomerenke.github.io/checkers

For development, clone the repository and npm start.

Configuration

The configuration can be changed at the top of App.js.

Key | Type | Meaning --- | --- |:--- pruning | boolean | false (default): AIs use Minimax/Maximin without pruning. This is practically faster, probably due to parallelization benefits from the functional style. true: AIs use Alpha-Beta search, which is asymptotically more efficient. limits: dumb, intermediate, smart | integer | Depth limit for each of the AIs, that is the number of rounds they try to predict/optimize. < 5 recommended for good performance. 1, 3, 4 by default. highlights | boolean | true (default): Show green highlights of movable checkers and possible moves by default. false Hide them by default. The user can change this in the rule section anyways. pauseTime | integer | Minimum pause time in ms before AI move steps. The AI calculations may take longer anyways.

Bugs

If you spot a bug, please create an issue. The game logs some information to the web console (ctrl shift i), which you could copy and paste (you do not need to format it). Thank you!

Overview

The checkers game is completely divided into three parts:

  • The GUI, containing a graphical representation of the board and the checkers, instructions for the user interaction, and help and error messages. It is written in object-oriented React and is found in this repository. The GUI reuses some of the game internals components to improve user interation.

  • The game internals, that is rule descriptions of which actions are applicable and how the game state changes with each action. It is written in function-oriented Javascript and is found in a separate repository, aima-checkers, because it could be the basis for other GUIs.

  • The game abstraction and the algorithms for searching instances of the game abstractions. These are described more or less explicitly in Artificial Intelligence - A Modern Approach (AIMA) by Stuart Russell and Peter Norvig, and they are implemented in the corresponding function-oriented Javascript package aima.js. In particular, the checkers game uses the Game class, which is an instance of the Problem class; and of the minimaxDecision algorithm and its variant alphaBetaSearch.

Structure

Display components

The display components are grouped into the board and the checkers:

  • The Board class consists of 64 Squares, which receive their board coordinates, as well as information about which squares are highlighted, and then choose their colour accordingly as black, white or green (to indicate that a move to this square is possible).

  • The checkers are not connected to the squares as they change their position, which means that if they are animated they will float on top of the board. The Checker instances are grouped into two class instances of CheckersGroup, one for each colour. Each CheckersGroup instance receives which of their checkers are highlighted, and they pass this on to the Checker instances.

  • Both squares and checkers have parentCallback methods which they use to communicate to the App class when they are clicked.

GUI logics

The App class orchestrates the working together of the display components and the rules backend, as well as with the AI.

Its core component is the this.state object, which contains the game state this.state.state (in the aima-checkers notation) as well as information about which checker has been selected by the user, which error message is currently displayed, and which settings have been chosen by the user (for the AI and the help highlights).

  • When a checker is selected, the highlight method is called and updates the state to highlight the potential squares to move to (if highlighting is enabled). When a square is selected afterwards, the move method is called and adds the move to the this.state.displayQueue.

  • After each move and after each call of the step method, the step method is called. It edits the this.state.displayQueue by dissecting multi-step moves into a list of single-step moves and executing the next step of that list (using the checkers.result method from aima-checkers). When the list is empty, it calls the aiMove method, where the AIs, if activated, make their own calls to the move method.

  • At any point during the game, the possible moves for the current player are received from the checkers.actions method from aima-checkers, and the end coordinates of the actions are passed to the board class for highlighting, if enabled.

Error messages

Error messages (for mistakes the user makes) are detected by the ErrorMessage class, which makes use of internal functions from aima-checkers for this purpose.