Giter VIP home page Giter VIP logo

draughts-ai's Introduction

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.