Skip to content

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.

Notifications You must be signed in to change notification settings

masonleon/ai-chess-agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ai-chess-agent

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:

Installation

OS Setup
Anaconda Setup
PyCharm Professional Setup
Version Control
Conda Environment
Python-Chess
Stockfish

OS Setup

  • Download Ubuntu Image ISO
  • Download Virtual Box or VMware
  • Install OS as a VM
install compiler dependencies:
$ sudo apt-get update
$ sudo apt-get install git make gcc g++

Anaconda Setup

install GUI dependencies:
$ sudo apt-get install libgl1-mesa-glx libegl1-mesa libxrandr2 libxrandr2 libxss1 libxcursor1 libxcomposite1 libasound2 libxi6 libxtst6
make temporary dir and download anaconda package:
$ cd ~
$ mkdir tmp
$ cd tmp
$ wget https://repo.anaconda.com/archive/Anaconda3-2019.10-Linux-x86_64.sh
check the hash

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
install package
$ 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
reset terminal window for installation to complete
$ source ~/.bashrc
verify anaconda install
$ conda list
verify python install
$ python

then

$ quit()
verify anaconda-navigator install
$ anaconda-navigator

then

$ ^C

PyCharm Professional Setup

download jetbrains toolbox tarball to tmp dir
$ wget https://download.jetbrains.com/toolbox/jetbrains-toolbox-1.16.6067.tar.gz
extract tarball to /opt dir
$ sudo tar -xzf jetbrains-toolbox-1.16.6067.tar.gz -C /opt
execute the jetbrains-toolbox binary and install PyCharm Professional 2019.3 from the popup message
$ cd /opt/jetbrains-toolbox-1.16.6067
$ ./jetbrains-toolbox
register licence
  • login to jetbrains-toolbox with JetBrains username and password approve application
  • open PyCharm Professional from the toolbox activate licence with JetBrains username and password

Version Control

setup Git

where name and email are your username and email
git config --global user.name "<name>" git config --global user.email "<email>"

setup PyCharm GitHub VCS
  • 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 Environment

create env
$ conda create --name ai-chess-agent python=3.6
$ conda install -n ai-chess-agent numpy pandas matplotlib
configure PyCharm project interpreter

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

Python-Chess

install to the env
$ cd ~/PycharmProjects/ai-chess-agent
$ conda activate ai-chess-agent
$ pip install python-chess

Stockfish

clone stockfish repo
$ git clone https://github.com/official-stockfish/Stockfish.git ~/PycharmProjects/ai-chess-agent
make the stockfish executable
$ cd Stockfish/src
$ make build ARCH=x86-64 COMP=gcc
make new engine dir and copy the stockfish executable
$ mkdir -p ~/PycharmProjects/ai-chess-agent/src/stockfish_engine && cp stockfish "$_"

Jupyter

start the server
cd ./src/driver_notebooks
jupyter notebook
execute the entire notebook of your choice

NOTE: DEPTH OF 3 TAKES A VERY LONG TIME!

jupyter nbconvert --to notebook --execute <notebook_name>.ipynb

About

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.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published