♟️ An evolutionary algorithm to help me learn how to play chess better.
Neural networks are the most popular method for developing modern chess bots. Stockfish and AlphaZero, some of the strongest chess bots currently known, rely on neural networks and the Monte Carlo search tree. The problem with this approach is I can't reverse engineer why the computer made a particular move. These AI systems are a "black box".
By contrast, evolutionary algorithms can generate an output we can more easily reverse engineer or visualize. In the case of this specific project, I'm evolving a mathematical equation which evaluates what chess move to make.
While evolutionary algorithms are different from neural networks in a number of important aspects, evolutionary algorithms still rely on the concept of "training" the computer to search a problem space for an optimal solution.
Install Node Version Manager.
$ nvm install && nvm use
$ npm ci
# Run engine tests
$ npm test -w @chess-evolutionary-algo/pattern-engine
If you need to debug chess boards with fen syntax, use the lichess chess editor. You can import a pgn here.
I've included a Terraform file that will deploy this project to Digital Ocean.
First, install Terraform CLI,
$ brew tap hashicorp/tap
$ brew install hashicorp/tap/terraform
Copy the example .env
file and fill out the values. See the inline comments on how to fill out the different values.
$ cp .env.example .env
Finally, create the infrastructure,
$ cd terraform
$ terraform init
# If you want to preview what is being created
$ terraform plan
$ terraform apply
By default, this will create three s-4vcpu-8gb
vm's in the nyc3
region, which are $0.07143
/hour (~$48
/month). If you want to change these defaults, you can supply the following arguments when running terraform,
$ terraform apply -var machine_count="3" -var machine_count="s-4vcpu-8gb"
To get a list of possible droplet sizes, run the following command,
$ doctl compute size list
When you're done experimenting, run the following the delete your infrastructure resources,
$ terraform destroy
I am not actively seeking contributions to this repository, but feel free to fork it and make your own changes.
This project is MIT Licensed.