It’s been a long time, but I’m back with another of my dinky code demos. This time it’s that old classic, the chess engine. For extra fun, we’re going to build it in TypeScript to run in the browser and we’ll give it an Angular 2 UI so you can play against it.
All the source code is on GitHub and can be found here.
I’m going to post a few articles here looking at what’s going on in the code. Hopefully there will be something here to interest a variety of readers, so the articles will be split across the different topics. You might want to know about the basics of computer chess, or the basics of Angular/TypeScript, or even the basics of web workers (i.e. background threads). In any case, the key word here is basic. This is not an advanced study of anything and as usual I’m not an expert on any of these topics. I just like writing code. Especially on the chess engine side, this discussion will be aimed at beginners. I do assume that you know how to play chess and you know the algebraic notation.
- How to make your computer play chess
- Chess engine code – laying the groundwork
- Chess engine code – running in the background
- Chess engine code – minimax
- Chess engine code – the evaluation function
- Angular 2 components – piece
- Angular 2 directive – square
The interesting parts of the code are in the
MoveGenerator.ts(discussed in this article).
Evaluation.ts(discussed in this article and this article).