Skip to content
A semantic chess game in JavaScript that allows doing and loading moves.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Semantic Chess

A semantic representation of a chess game in JavaScript that allows doing and loading moves. It will generate the corresponding RDF, SPARQL updates, and inbox notifications. It is used in solid-chess, a decentralized chess game, based on Solid.

The full documentation can be found here.


You can install the library via

npm i semantic-chess


Create a new chess game

In the example below we create a new game and do a single move. We print the corresponding SPARQL update for that move together the notification that should be send to the inbox of the opponent.

const SemanticChess = require('semantic-chess').SemanticChess;

const chess = new SemanticChess({
  url: '',
  userWebId: '',
  userDataUrl: '',
  opponentsWebId: '',
  name: 'My first chess game!'

const move = chess.doMove('e4');

//   <> <> <>;
//     <> <>.
//   <> <> <>;
//     <> "e4"^^<>.
// }

// <> <> <>.

Note that the URLs of the moves might be different for every run, as a unique id is generated for every move.

Load a chess game via its url

In the example below we load a game from its url. The Loader needs a fetch function that will be used to fetch the data. The fetch from solid-auth-client is a possibility. We also need to provide the WebId of the current user, so the game know when a move is valid. Furthermore, the base URL that is used for new moves is also provided. This can either be a string or a function that returns a string.

const Loader = require('semantic-chess').Loader;
const auth = require('solid-auth-client);

const loader = new Loader(auth.fetch);
const chess = await loader.loadFromUrl('', '', '');


The test are executed via

npm test

The test files can be found in the folder lib and have the extension test.js.


The documentation is generated via

npm run doc

You can find the resulting HTML in the folder docs.


© 2018 Pieter Heyvaert, MIT License

You can’t perform that action at this time.