27

A step-by-step guide to building a simple chess AI (2017)

 5 years ago
source link: https://www.tuicool.com/articles/hit/JVJbQnF
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Let’s explore some basic concepts that will help us create a simple chess AI:

  • move-generation
  • board evaluation
  • minimax
  • and alpha beta pruning.

At each step, we’ll improve our algorithm with one of these time-tested chess-programming techniques. I’ll demonstrate how each affects the algorithm’s playing style.

You can view the final AI algorithm here on GitHub .

Step 1: Move generation and board visualization

We’ll use the chess.js library for move generation, and chessboard.js for visualizing the board. The move generation library basically implements all the rules of chess. Based on this, we can calculate all legal moves for a given board state.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK