https://github.com/hsankesara/draughts-ai
AI based checkers game-bot
https://github.com/hsankesara/draughts-ai
ai artificial-intelligence checkers-game gamebot
Last synced: 8 months ago
JSON representation
AI based checkers game-bot
- Host: GitHub
- URL: https://github.com/hsankesara/draughts-ai
- Owner: Hsankesara
- License: mit
- Created: 2019-03-07T16:49:57.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-09-22T09:26:56.000Z (over 3 years ago)
- Last Synced: 2025-04-03T04:11:20.285Z (about 1 year ago)
- Topics: ai, artificial-intelligence, checkers-game, gamebot
- Language: Python
- Homepage:
- Size: 403 KB
- Stars: 51
- Watchers: 2
- Forks: 21
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Draughts-AI
## Introduction
The game of checkers is considered a complicated game with
possible legal positions in the English draughts version (
board) alone (much more on higher dimensions). In this attempt to create a game agent, a tree traversal approach has been used. This approach is not only fast but also efficient given that good heuristics are used. The agent has been created which is capable of playing the game of draughts or checkers with a remarkable win rate against average players. Draughts is a 1vs1 zero-sum game. Minimax or Minimax algorithm is best suited for such types of games. Following is the development procedure practised during the development of the project.
1. Implemented a basic Minimax Agent with limited depth.
2. Applied ⍺-β pruning.
3. Improved the evaluation functions.
## Evaluation Functions
Two types of evaluation functions have been used depending upon the state of the game. These are mid evaluation and end game evaluation function. Following is the report for the same.
List all the evaluation functions:
### Mid Evaluation
#### Piece to Value

Where
and
are the player’s and opponent’s pawns and
and
are the player’s and Opponent’s Kings respectively.
#### Piece and Board part to value

Where
and
are the player’s and Opponent’s Pawns in their own respective halves and
and
are their Pawns in their respective enemies halves.
and
are the player’s and Opponent’s Kings respectively.
#### Piece and Row to value

Where
and
is the player’s and Opponent’s Pawns and
and
are the player’s and Opponent’s Kings respectively.
,
are the row number of the respective piece.
#### Piece and Board part to value (modified)

Where
and
is the player’s and Opponent’s Pawns in their own respective halves and
and
are their Pawns in their respective enemies’ halves.
and
are the player’s and Opponent’s Kings respectively.
is the number of pieces on the board.
### End Evaluation
#### Sum of Distances
= Distance of ith king of the player from jth King of the adversary.

where
is total number of kings of the player in the board and
is total number of kings of the adversary in the board.
Minimise
if player has more number of pieces than adversary else maximise.
#### Farthest Piece
= Distance of ith King of player from jth King of the enemy.

where
is total number of kings of the player in the board and
is total number of kings of the adversary in the board.
Minimise
if player has more number of pieces than adversary else maximise.
## How to run the code
First install Requirements
```
pip3 install -r requirements.txt
```
### Run the Game
```bash
python3 main.py
```
**You can tweak the parameters of the game bot from [main](main.py) file**
## Conclusion
1. Heuristics can be drastically improved by adding specific features.
2. The depth of the game tree has a significant influence on the quality of the computer player.
3. There's a tradeoff between calculation time and quality of the game.
4. It is not efficient to use Minimax without optimizations while with them it can be a good solution.
5. Alpha-Beta pruning is exponentially improving in comparison to Minimax as the depth grows.
6. Certain heuristics are clearly better than others but some of the “bad” ones still work well in some cases.
## References
1. Two player draughts game template has been taken from [Pygame-Checkers](https://github.com/everestwitman/Pygame-Checkers/)
## Contributing
Found a bug? Create an **[issue](https://github.com/Hsankesara/Draughts-AI/issues/new)**.