This project implements a simple chess AI using the Min-Max algorithm with evaluation functions. The game can be played in different modes, including human vs bot and bot vs bot.
Make sure you have Python installed on your system. Additionally, you'll need to install the following Python packages:
-
Install Python:
Download and install Python from the official website: Python Downloads
-
Install pygame:
pip install pygame
-
Install Python-Chess:
pip install python-chess
-
Install StockFish:
https://stockfishchess.org/download/ # we use windows OS and have installed the installed windows version of stockfish to use in Stockfish_FilePath.py
Human vs bot:
- initially navigate to HumanVSbot.py and uncomment the last two lines of the code.
- if you are using it in IDE [pycharm], you can directly run the program and enjoy playing the game.
- if you want to run it through terminal
python HumanVSbot.py
Stockfish vs bot:
- initially navigate to StockfishVSbot.py and uncomment the last two lines of the code.
- also navigate to Stockfish_FilePath.py and update your stockfish excecutable file path.
- if you are using it in IDE [pycharm], you can directly run the program and enjoy watching the game between stockfish and MIN - MAX.
- if you want to run it through terminal
python StockfishVSbot.py
Alphago Zero:
- To implement Alphago Zero, we are lacking the computational power. Because, this algorithm self plays from both the sides and learn from each move, It will take months to train the basic model to beat the level 3 minimax.
Q learning with reward based on final game result and a random opponent:
- What we did try was to implement a Q-Learning model for almost 50000 iterations, where in reward was presented basing on the result of the game.
- Opponent was a random agent, picking up random move out of all legal moves.
- Our bot still couldn't come up with a better strategy than MinMax.
Q learning with reward function, and a specific opponent:
- Multiple strategies were engaged to reward the bot, like capture based reward, and overall game based reward.
- Here the opponent was engaged on a specific target, like Greedy choice, first legal move as choice and random choice.
- Capture based reward:
- Game ends after 25 moves
- Maximum captures, max reward.
- Uses Q Learning as technique.
- Game based:
- Plays general rule based chess and learns from it.
- Uses Monte carlo search
- It was learning forever…….!
- Capture based reward:
Stockfish vs Bot game:
- Move based score evaluation for both stockfish [green .] and bot [red X], please navigate to screenshots or TerminalLog_after50games.txt to view all game details.
So as we see after certain point of the game we see a huge spike in
difference of score between players showing a bad move made by Min max bot.
- 50 concecute games later, graph of each game vs number of total moves per each game
max number of moves = 81 minimum number of moves = 21 Average number of moves over 50 games = 38.92
- please checkout out ppt of the project at : https://tinyurl.com/535project