This project aims to create a chess playing AI agent that can rationally pick moves and win a reasonable number of times using the Minimax and Minimax with Alpha-beta pruning algorithms. We use different heuristic evaluation methods to improve the performance of our agents against a random agent.
Using the Stockfish engine, we demonstrate that due to the extremely large state space of chess, Minimax and Minimax with Alpha-beta pruning in their basic implementation are not optimal approaches for an AI agent.
This repository is part of Mason Leon and Naveen Kumar Chiluka's final report for Dr. Lawson L.S. Wong's graduate-level Fall 2019 CS 5100: Foundations of Artificial Intelligence course at Khoury College of Computer Sciences, Northeastern University, Boston, MA.
Please visit the https://github.com/masonleon/ai-chess-agent/tree/master/reports to learn more about the project.
Before installing, you may find the following projects, libraries, and references used in this project of interest:
- Programming a Chess Player
- Stockfish
- Python-Chess
- Syzygy endgame tablebases
- Syzygy endgame tablebase API
- lila-tablebase API
- Chess Programming Wiki
- Russell And Norvig's Artificial Intelligence: A Modern Approach
- AIMA Python Implementation
- AIMA Algorithm Pseudocode
OS Setup
Anaconda Setup
PyCharm Professional Setup
Version Control
Conda Environment
Python-Chess
Stockfish
- Download Ubuntu Image ISO
- Download Virtual Box or VMware
- Install OS as a VM
$ sudo apt-get update
$ sudo apt-get install git make gcc g++
$ sudo apt-get install libgl1-mesa-glx libegl1-mesa libxrandr2 libxrandr2 libxss1 libxcursor1 libxcomposite1 libasound2 libxi6 libxtst6
$ cd ~
$ mkdir tmp
$ cd tmp
$ wget https://repo.anaconda.com/archive/Anaconda3-2019.10-Linux-x86_64.sh
check against https://docs.anaconda.com/anaconda/install/hashes/Anaconda3-2019.10-Linux-x86_64.sh-hash/
$ sha256sum https://repo.anaconda.com/archive/Anaconda3-2019.10-Linux-x86_64.sh
$ bash ~/home/<your-username>/tmp/Anaconda3-2019.10-Linux-x86_64.sh`
- press
enter
key several times for agreement - type
yes
for default install location - type
yes
to initialize Anaconda3 when installer complete
$ source ~/.bashrc
$ conda list
$ python
then
$ quit()
$ anaconda-navigator
then
$ ^C
$ wget https://download.jetbrains.com/toolbox/jetbrains-toolbox-1.16.6067.tar.gz
$ sudo tar -xzf jetbrains-toolbox-1.16.6067.tar.gz -C /opt
$ cd /opt/jetbrains-toolbox-1.16.6067
$ ./jetbrains-toolbox
- login to jetbrains-toolbox with JetBrains username and password approve application
- open PyCharm Professional from the toolbox activate licence with JetBrains username and password
where name and email are your username and email
git config --global user.name "<name>" git config --global user.email "<email>"
- open PyCharm and setup IDE, login to GitHub
- If you are a contributor:
- select get from version control
- select ai-chess-agent and clone
- Otherwise:
- make a new PyCharm project
$ git clone https://github.com/masonleon/ai-chess-agent.git ~/PycharmProjects/
$ conda create --name ai-chess-agent python=3.6
$ conda install -n ai-chess-agent numpy pandas matplotlib
select Conda Environment, existing environment
- Interpereter:
/home/<your-username>/anaconda3/envs/ai-chess-agent/bin/python
- Conda Executable:
/home/<your-username>/anaconda3/bin/conda
- Make Available to all Projects:
Yes
$ cd ~/PycharmProjects/ai-chess-agent
$ conda activate ai-chess-agent
$ pip install python-chess
$ git clone https://github.com/official-stockfish/Stockfish.git ~/PycharmProjects/ai-chess-agent
$ cd Stockfish/src
$ make build ARCH=x86-64 COMP=gcc
$ mkdir -p ~/PycharmProjects/ai-chess-agent/src/stockfish_engine && cp stockfish "$_"
cd ./src/driver_notebooks
jupyter notebook
NOTE: DEPTH OF 3 TAKES A VERY LONG TIME!
jupyter nbconvert --to notebook --execute <notebook_name>.ipynb