A rudimentary chess engine and command-line interface.
pdchess3 : Portable Didactic Chess, incarnation number 3.
A rudimentary chess engine and command-line interface.
Written in TypeScript for Node.js and npm.
Obligatory BadgeFest:
pdchess3
To build pdchess3
and install the command-line interface, do this:
npm run all
npm link
pdchess3
After npm link
has been run, pdchess3
can be invoked from the command line using this syntax:
pdchess3 [White player configuration] [Black player configuration]
… where each player’s configuration is in one of two forms:
pdchess
‘s game engine, using ‘max ply’ as the initial basic maximum lookahead depth.For example, if you want to play White while the computer plays Black, you could do this:
pdchess3 h c 5
If you want the computer to play a slow game against itself, you could do this:
pdchess3 c 6 c 6
You can use nice
to launch the pdchess3
process with a lower priority; e.g.:
nice -n 20 pdchess3 c 5 c 5
pdchess3
A fairly standard command syntax is used to specify moves; e.g.:
Type ‘exit’ at the move prompt to end the game and exit the app.
$ pdchess3 h c 5
8 rnbqkbnr
7 pppppppp
6 + + + +
5 + + + +
4 + + + +
3 + + + +
2 PPPPPPPP
1 RNBQKBNR
abcdefgh
Move 1: White
> e2-e4
Matched the manual move 'e2-e4' in the opening book.
Elapsed time for this move: 2 milliseconds
White's move: e2-e4
8 rnbqkbnr
7 pppppppp
6 + + + +
5 + + + +
4 + +P+ +
3 + + + +
2 PPPP PPP
1 RNBQKBNR
abcdefgh
Move 1: Black
Opening: Nimzovich Defence
Black: Automated: Using this move from the opening book: b8-c6
Elapsed time for this move: 1 millisecond
Black's move: b8-c6
8 r+bqkbnr
7 pppppppp
6 +n+ + +
5 + + + +
4 + +P+ +
3 + + + +
2 PPPP PPP
1 RNBQKBNR
abcdefgh
Move 2: White
> exit
Exiting...
$
process.env.NODE_ENV
to 'test'
if it’s not set to something else. You can use that in your configuration to conditionally setup only the compilation needed for Jest, e.g.
// babel.config.js
module.exports = api => {
const isTest = api.env('test');
// You can use isTest to determine what presets and plugins to use.
// If isTest then target es2015; else target es6 (to support Angular 10).
return {
// ...
};
};