Programming a chess engine in C++
Podsechin, Igor (2022)
Podsechin, Igor
2022
Tieto- ja sähkötekniikan kandidaattiohjelma - Bachelor's Programme in Computing and Electrical Engineering
Informaatioteknologian ja viestinnän tiedekunta - Faculty of Information Technology and Communication Sciences
This publication is copyrighted. You may download, display and print it for Your own personal use. Commercial use is prohibited.
Hyväksymispäivämäärä
2022-05-09
Julkaisun pysyvä osoite on
https://urn.fi/URN:NBN:fi:tuni-202205265282
https://urn.fi/URN:NBN:fi:tuni-202205265282
Tiivistelmä
Chess is one of the world’s oldest board games and also probably one of the most popular ones. Ever since computers were invented in the 1940’s, the science community has tried to create independently playing chess programs. This bachelor thesis’ research question could be summarized by the following question: “How can a computer be programmed to play chess?”. Basically this paper investigates how a chess engine can be written using the C++ programming language. The aim is to go through the process step by step in such a fashion that a person who knows the rules of chess and has experience in programming could read through the text and get a general overview of how a traditional chess engine operates.
The research problem can be divided into smaller parts, out of which each has an important role when writing a chess engine. First we have to define how to mathematically model the chessboard and the pieces in such a way that the computer understands them. Then the ruleset and movement of the pieces have to be added in as well. An integral part of this is also making sure that the legality of moves stays intact or otherwise the program may produce bad or even totally illegal results. The last section describes how the minimax algorithm is used to select the best move from the game tree and how the evaluation function is used to score the chess board.
In the end the chess engine is evaluated and possible improvements are presented. As a result it becomes clear that even though the final result is quite far from the current cutting-edge engines, it still provides a rather challenging opponent. Possible improvements include a better search algorithm, introducing parallelism to the program and improving the evaluation function. In addition to this the popularity of neural networks has recently sky-rocketed, which has also had an effect on chess programming.
The research problem can be divided into smaller parts, out of which each has an important role when writing a chess engine. First we have to define how to mathematically model the chessboard and the pieces in such a way that the computer understands them. Then the ruleset and movement of the pieces have to be added in as well. An integral part of this is also making sure that the legality of moves stays intact or otherwise the program may produce bad or even totally illegal results. The last section describes how the minimax algorithm is used to select the best move from the game tree and how the evaluation function is used to score the chess board.
In the end the chess engine is evaluated and possible improvements are presented. As a result it becomes clear that even though the final result is quite far from the current cutting-edge engines, it still provides a rather challenging opponent. Possible improvements include a better search algorithm, introducing parallelism to the program and improving the evaluation function. In addition to this the popularity of neural networks has recently sky-rocketed, which has also had an effect on chess programming.
Kokoelmat
- Kandidaatintutkielmat [8253]