An amateur attempt at breeding a chess-playing AI.
This program attempts to create a chess-playing AI by playing prospective AIs against each and letting the winners produce mutated copies. As evidence that this has a chance of working, here's a plot from a recent run of the value that the AIs place on each type of piece.
It took awhile (tens of thousands of generations), but it did figure out the correct ordering and relative value of the major pieces. Pawns have other genes measuring the influence of their positions, so their absolute value tends to be zero instead of the traditional one.
- Install
gcc
orclang
- Clone this repository to your computer.
./create_Makefile gcc
(orclang
)make release
- Clone this repository to your computer.
- Open Genetic_Chess.sln in Visual Studio and compile.
make user_manual
for the User Manual PDF (requirespdflatex
)- Or compile
doc/reference.tex
with TexWriter or similar.
- Or compile
make code_docs
for HTML source code references- Or generate with Doxygen
make docs
for both
- Install a chess GUI (e.g., cutechess)
- Create a new engine with the compiled executable and with the command-line
parameters
-genetic genome_example.txt
- After running a gene pool, you can replace the
genome_example.txt
argument with the file name and ID number of the best specimen from the gene pool.
- After running a gene pool, you can replace the
- Edit
gene_pool_config_example.txt
to adjust the number of simultaneous games to a number less than or equal to the number of processors on your computer. <bin location>/genetic_chess -gene-pool gene_pool_config_example.txt
- If compiling with Visual Studio, look in x86/Release or x64/Release for the compiled program.
- Every few hours or days, pause the gene pool with
Ctrl-Z
(Linux) orCtrl-C
(on Windows) and runpython3 analysis/run_genetic_plots.py gene_pool_config_example.txt
to generate plots and other data showing the evolution and behavior of the specimens.- This script requires Python 3.9 or later,
numpy
, andmatplotlib
to run.
- This script requires Python 3.9 or later,