项目作者: tom-weatherhead

项目描述 :
A rudimentary chess engine and command-line interface.
高级语言: TypeScript
项目地址: git://github.com/tom-weatherhead/pdchess3.git
创建时间: 2020-06-06T01:59:02Z
项目社区:https://github.com/tom-weatherhead/pdchess3

开源协议:MIT License

下载




pdchess3

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:

codeclimate
git
github
npm
terminal
travis
typescript

status
build status
npm version
latest tag
npm total downloads
watchers
stars
issues
forks
contributors
branches
releases
commits
last commit
types
install size
known vulnerabilities
lines of code
technical debt
maintainability
test coverage
tested with jest
code style: prettier
license
FOSSA Status

Building pdchess3

To build pdchess3 and install the command-line interface, do this:

  1. npm run all
  2. npm link

Launching pdchess3

After npm link has been run, pdchess3 can be invoked from the command line using this syntax:

  1. pdchess3 [White player configuration] [Black player configuration]

… where each player’s configuration is in one of two forms:

  • h: Human. The player’s moves will be entered via the standard input.
  • c [max ply]: Computer. The player’s moves will be calculated by 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:

  1. pdchess3 h c 5

If you want the computer to play a slow game against itself, you could do this:

  1. pdchess3 c 6 c 6

You can use nice to launch the pdchess3 process with a lower priority; e.g.:

  1. nice -n 20 pdchess3 c 5 c 5

Playing pdchess3

A fairly standard command syntax is used to specify moves; e.g.:

  • e2-e4 : An initial pawn move by White
  • Ng8-f6 : An initial knight move by Black
  • Qa1xd8 : A capturing move by a queen
  • O-O : Castle on the kingside
  • O-O-O : Castle on the queenside

Type ‘exit’ at the move prompt to end the game and exit the app.

Example

  1. $ pdchess3 h c 5
  2. 8 rnbqkbnr
  3. 7 pppppppp
  4. 6 + + + +
  5. 5 + + + +
  6. 4 + + + +
  7. 3 + + + +
  8. 2 PPPPPPPP
  9. 1 RNBQKBNR
  10. abcdefgh
  11. Move 1: White
  12. > e2-e4
  13. Matched the manual move 'e2-e4' in the opening book.
  14. Elapsed time for this move: 2 milliseconds
  15. White's move: e2-e4
  16. 8 rnbqkbnr
  17. 7 pppppppp
  18. 6 + + + +
  19. 5 + + + +
  20. 4 + +P+ +
  21. 3 + + + +
  22. 2 PPPP PPP
  23. 1 RNBQKBNR
  24. abcdefgh
  25. Move 1: Black
  26. Opening: Nimzovich Defence
  27. Black: Automated: Using this move from the opening book: b8-c6
  28. Elapsed time for this move: 1 millisecond
  29. Black's move: b8-c6
  30. 8 r+bqkbnr
  31. 7 pppppppp
  32. 6 +n+ + +
  33. 5 + + + +
  34. 4 + +P+ +
  35. 3 + + + +
  36. 2 PPPP PPP
  37. 1 RNBQKBNR
  38. abcdefgh
  39. Move 2: White
  40. > exit
  41. Exiting...
  42. $

History

  • I witnessed the University of Waterloo host a tournament of Othello (Reversi)-playing programs in 1992; these programs played each other by sending game data over the Internet.
  • After creating my own rudimentary Othello-playing program in C, I chose chess as the next problem domain to tackle. The result was incarnation number 1 of pdchess, which was written in C in 1993. I began the project during my university exams in April. This version had a console interface. I started developing it on the univerity’s Unix computers, then e-mailed the source code to my e-mail address at Digital Equipment of Canada in Ottawa, where I worked during the summer of 1993. At Digital, I ported the code to compile and run on the VAX/VMS operating system, and I continued development. In August 1993, I e-mailed the source code back to Waterloo. Just before finishing my final term in April 1994, I copied the source code to a 3.5-inch floppy and took it with me.
  • During the summer of 1994, I modified the code to work on my brand-new computer (an Intel 80486SX PC clone running Windows 3.1, with 640 KB + 3072 KB of RAM and a 360 MB hard drive, plus 3.5-inch and 5.25-inch floppy drives) via Borland Turbo C++ 3.1. I created a GUI for pdchess using Turbo C++’s OWL (Object Windows Library) framework. (OWL was analogous to Microsoft’s MFC.)
  • Incarnation number 2 of pdchess was written in C++ in 2002, after I had read Bjarne Stroustrup’s book on the language.
  • Incarnation number 3 of pdchess was written in Typescript in Beijing, China in February and March 2020, during the COVID-19 coronavirus pandemic.
  • pdchess is also known to some as ‘partly done chess’. :-)

TODO

  • Jest will set 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.
  1. // babel.config.js
  2. module.exports = api => {
  3. const isTest = api.env('test');
  4. // You can use isTest to determine what presets and plugins to use.
  5. // If isTest then target es2015; else target es6 (to support Angular 10).
  6. return {
  7. // ...
  8. };
  9. };
  • ? Use Webpack, then use Jest to test the Webpacked version of pdchess3?

License

MIT