Skip to content

Hsankesara/Draughts-AI

Repository files navigation

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.
AI vs Player I AI vs Player II
AI vs Player I AI vs AI II

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

python3 main.py

You can tweak the parameters of the game bot from main 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

Contributing

Found a bug? Create an issue.