|
|
Anatomy of a chess program Most chess programs can be broken down into several key components:
- The State - where all the pieces are, who's go it is, castling, en-passant, 50 move draw, and move history for 3 repetitions
- The User Interface - input/output of moves
- The Move Generator - given the state of a game, returns all possible legal moves
- The Move Applier - given the state of a game and a move, returns the new state of the game. There is often a reverse function to undo a move and revert the current state back to the state it was before the move was played
- The Rating Algorithm - given the state of a game, returns a score indicating who is winning and by how much. This is different for each chess program and governs the strength and style of the computer player
- The Search Algorithm - given a state of a game, searches for the best move which can be played. There are several different algorithms, which govern the speed the computer can work out its best move, and how far ahead the computer can search
I'll attempt to describe how I've implemented each section and the problems and solutions I've encountered at each stage.
Please bear with me as I get these sections written over the coming weeks.
The State of Play
The User Interface
The Move Generator
The Move Applier
The Rating Algorithm
The Search Algorithm
Putting it all together
|
|