Chess engine code – laying the groundwork

This article is part of a series – the contents page is here.

In the last article we covered the very basic theory of a chess engine.  Time to write some code!  Before we can get to the interesting stuff we need to lay the groundwork with a few elementary types and enums.  You can see all of these in the ChessElements.ts file.  The main ones are PieceType, BoardSquare, Board and GameMove.

Continue reading

Shallow Thought – an Angular 2 chess player

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.

Continue reading

How to make your computer play chess

This article is part of a series – the contents page is here.

Let’s start somewhere near the beginning with a few definitions:

  • position is the state of the chess board at a given point.  It includes the locations of the pieces and the knowledge of whose turn it is to move next.  It also includes subtle stuff like whether the players have moved their kings or rooks, which affects their ability to castle.
  • move is a single move by one player, such as White pushing the pawn from e2 to e4.  Each move takes a position and creates a new position.
  • line is a sequence of moves.  For example, the line 1. e4 e5 2. Nf3 Nc6 3. Bb5 is the start of the Ruy Lopez opening.
Continue reading