SebLague / Chess-Challenge

Create your own tiny chess bot!
https://www.youtube.com/watch?v=Ne40a5LkK6A
MIT License
1.78k stars 1.07k forks source link

Create Chess Bot #500

Closed sweetbaboo-1 closed 1 month ago

sweetbaboo-1 commented 1 month ago

Chess AI written by me.

Piece Values and Piece-Square tables were taken from https://www.chessprogramming.org/Simplified_Evaluation_Function.

The same website also inspired several of the techniques used. Alpha-Beta Nega Max, Iterative Deepening, and Quiesce were all inspired by articles on chessprogramming.com.

Alpha-Beta is a backtracking algorithm that essentially plays all of the possible current moves, then uses an evaluation function to determine the quality of the position after a move was made. This is performed recursively for as many layers deep as desired. Iterative deepening is a technique used to go as deeply as possible within a specific amount of time. After each move is evaluated, a timer is checked, and if the time limit has been exceeded, the best-found move is returned. This allows the AI to search as deeply as possible in board states with few possible moves (endgame) and not to waste all of the allotted time searching a single move in the early to mid-game where there are lots of possible moves.

Quiesce is run when we have looked as many moves into the future as we can. It then evaluates all possible captures from that move and evaluates them to return the final score for a given move. This prevents the bot from making a move that looks great but didn't consider the opponent's immediate next move. For example, taking a knight with your queen looks good, until you realize that your queen is now vulnerable. Quiesce prevents poor trades.