{"id":17835201,"url":"https://github.com/hsankesara/draughts-ai","last_synced_at":"2025-10-24T02:01:52.851Z","repository":{"id":87573192,"uuid":"174384724","full_name":"Hsankesara/Draughts-AI","owner":"Hsankesara","description":"AI based checkers game-bot","archived":false,"fork":false,"pushed_at":"2022-09-22T09:26:56.000Z","size":413,"stargazers_count":51,"open_issues_count":1,"forks_count":21,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-03T04:11:20.285Z","etag":null,"topics":["ai","artificial-intelligence","checkers-game","gamebot"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Hsankesara.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-07T16:49:57.000Z","updated_at":"2025-02-23T08:18:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"08830bf7-cb53-4aa2-bad5-5080fc838679","html_url":"https://github.com/Hsankesara/Draughts-AI","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Hsankesara/Draughts-AI","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hsankesara%2FDraughts-AI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hsankesara%2FDraughts-AI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hsankesara%2FDraughts-AI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hsankesara%2FDraughts-AI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Hsankesara","download_url":"https://codeload.github.com/Hsankesara/Draughts-AI/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hsankesara%2FDraughts-AI/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267202456,"owners_count":24052252,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-26T02:00:08.937Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","artificial-intelligence","checkers-game","gamebot"],"created_at":"2024-10-27T20:17:45.976Z","updated_at":"2025-10-24T02:01:52.845Z","avatar_url":"https://github.com/Hsankesara.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Draughts-AI\n\n## Introduction\n\nThe game of checkers is considered a complicated game with \u003cimg src=\"/tex/dbab8293b66086459d4464168538e091.svg?invert_in_darkmode\u0026sanitize=true\" align=middle width=29.54351234999999pt height=26.76175259999998pt/\u003e possible legal positions in the English draughts version ( \u003cimg src=\"/tex/5786a8e466b20e868a9d801cbb6c4521.svg?invert_in_darkmode\u0026sanitize=true\" align=middle width=36.52961069999999pt height=21.18721440000001pt/\u003e 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.\n\n1. Implemented a basic Minimax Agent with limited depth.\n2. Applied ⍺-β pruning.\n3. Improved the evaluation functions.\n\n\u003ctable\u003e\n    \u003ctr\u003e\n        \u003ctd\u003e\u003cimg src=\"imgs/checker_gif_1.gif\" alt=\"AI vs Player I\"\u003e\u003c/td\u003e\n        \u003ctd\u003e\u003cimg src=\"imgs/checker_gif_4.gif\" alt=\"AI vs Player II\"\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003e\u003cimg src=\"imgs/checker_gif_7.gif\" alt=\"AI vs Player I\"\u003e\u003c/td\u003e\n        \u003ctd\u003e\u003cimg src=\"imgs/checker_gif_8.gif\" alt=\"AI vs AI II\"\u003e\u003c/td\u003e\n    \u003c/tr\u003e\n\u003c/table\u003e\n\n## Evaluation Functions\n\nTwo 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.\nList all the evaluation functions:\n\n### Mid Evaluation\n\n#### Piece to Value\n\n\u003cimg src=\"/tex/bf0a32a5f35b6300f9b8952604ae4499.svg?invert_in_darkmode\u0026sanitize=true\" align=middle width=273.21628949999996pt height=22.465723500000017pt/\u003e\n\nWhere \u003cimg src=\"/tex/ef0de0b48cb187b636ae34b0aea8c1db.svg?invert_in_darkmode\u0026sanitize=true\" align=middle width=15.20454704999999pt height=22.465723500000017pt/\u003e and \u003cimg src=\"/tex/9bb870c8b2e1c548bbfae64f1f287b01.svg?invert_in_darkmode\u0026sanitize=true\" align=middle width=28.199971799999986pt height=22.465723500000017pt/\u003e are the player’s and opponent’s pawns and \u003cimg src=\"/tex/655ca15e2b101fb431577b12d4442580.svg?invert_in_darkmode\u0026sanitize=true\" align=middle width=18.61211054999999pt height=22.465723500000017pt/\u003e and \u003cimg src=\"/tex/0bbd4f73c8c87e1bf32d188183e057ec.svg?invert_in_darkmode\u0026sanitize=true\" align=middle width=31.607535299999988pt height=22.465723500000017pt/\u003e are the player’s and Opponent’s Kings respectively.\n\n#### Piece and Board part to value\n\n\u003cimg src=\"/tex/35f6dbbfe732e7296273ed13dd89bc75.svg?invert_in_darkmode\u0026sanitize=true\" align=middle width=613.57211025pt height=24.65753399999998pt/\u003e\n\nWhere \u003cimg src=\"/tex/1506c48c2e589e3eb1276d619c08abc6.svg?invert_in_darkmode\u0026sanitize=true\" align=middle width=43.04128784999999pt height=22.465723500000017pt/\u003e and \u003cimg src=\"/tex/0fca7f06c4e7b48a1626a0222076e53c.svg?invert_in_darkmode\u0026sanitize=true\" align=middle width=56.03671259999999pt height=22.465723500000017pt/\u003e are the player’s and Opponent’s Pawns in their own respective halves and \u003cimg src=\"/tex/799e49842e138209ff82830d45ab7d28.svg?invert_in_darkmode\u0026sanitize=true\" align=middle width=43.28669234999999pt height=22.465723500000017pt/\u003e and \u003cimg src=\"/tex/e06f07044ecba1e22f83d6b32b22410b.svg?invert_in_darkmode\u0026sanitize=true\" align=middle width=56.28211709999999pt height=22.465723500000017pt/\u003e are their Pawns in their respective enemies halves.\n\u003cimg src=\"/tex/655ca15e2b101fb431577b12d4442580.svg?invert_in_darkmode\u0026sanitize=true\" align=middle width=18.61211054999999pt height=22.465723500000017pt/\u003e and \u003cimg src=\"/tex/0bbd4f73c8c87e1bf32d188183e057ec.svg?invert_in_darkmode\u0026sanitize=true\" align=middle width=31.607535299999988pt height=22.465723500000017pt/\u003e are the player’s and Opponent’s Kings respectively.\n\n#### Piece and Row to value\n\n\u003cimg src=\"/tex/f2e6ee47dada6de07618ebd5e8e7dc06.svg?invert_in_darkmode\u0026sanitize=true\" align=middle width=535.8073182pt height=24.65753399999998pt/\u003e\n\nWhere \u003cimg src=\"/tex/ef0de0b48cb187b636ae34b0aea8c1db.svg?invert_in_darkmode\u0026sanitize=true\" align=middle width=15.20454704999999pt height=22.465723500000017pt/\u003e and \u003cimg src=\"/tex/9bb870c8b2e1c548bbfae64f1f287b01.svg?invert_in_darkmode\u0026sanitize=true\" align=middle width=28.199971799999986pt height=22.465723500000017pt/\u003e is the player’s and Opponent’s Pawns and \u003cimg src=\"/tex/655ca15e2b101fb431577b12d4442580.svg?invert_in_darkmode\u0026sanitize=true\" align=middle width=18.61211054999999pt height=22.465723500000017pt/\u003e and \u003cimg src=\"/tex/0bbd4f73c8c87e1bf32d188183e057ec.svg?invert_in_darkmode\u0026sanitize=true\" align=middle width=31.607535299999988pt height=22.465723500000017pt/\u003e are the player’s and Opponent’s Kings respectively. \u003cimg src=\"/tex/212f899c5235a861a1f6146dc8d1582f.svg?invert_in_darkmode\u0026sanitize=true\" align=middle width=13.520829299999992pt height=14.15524440000002pt/\u003e, \u003cimg src=\"/tex/3cf87ea38a615ed99e0232f8ed9431fe.svg?invert_in_darkmode\u0026sanitize=true\" align=middle width=12.067218899999991pt height=14.15524440000002pt/\u003e are the row number of the respective piece.\n\n#### Piece and Board part to value (modified)\n\n\u003cimg src=\"/tex/06566d53dff3c19f365551bb5ba11162.svg?invert_in_darkmode\u0026sanitize=true\" align=middle width=442.48182660000003pt height=33.20539859999999pt/\u003e\n\nWhere \u003cimg src=\"/tex/1506c48c2e589e3eb1276d619c08abc6.svg?invert_in_darkmode\u0026sanitize=true\" align=middle width=43.04128784999999pt height=22.465723500000017pt/\u003e and \u003cimg src=\"/tex/0fca7f06c4e7b48a1626a0222076e53c.svg?invert_in_darkmode\u0026sanitize=true\" align=middle width=56.03671259999999pt height=22.465723500000017pt/\u003e is the player’s and Opponent’s Pawns in their own respective halves and \u003cimg src=\"/tex/799e49842e138209ff82830d45ab7d28.svg?invert_in_darkmode\u0026sanitize=true\" align=middle width=43.28669234999999pt height=22.465723500000017pt/\u003e and \u003cimg src=\"/tex/e06f07044ecba1e22f83d6b32b22410b.svg?invert_in_darkmode\u0026sanitize=true\" align=middle width=56.28211709999999pt height=22.465723500000017pt/\u003e are their Pawns in their respective enemies’ halves. \u003cimg src=\"/tex/655ca15e2b101fb431577b12d4442580.svg?invert_in_darkmode\u0026sanitize=true\" align=middle width=18.61211054999999pt height=22.465723500000017pt/\u003e and \u003cimg src=\"/tex/0bbd4f73c8c87e1bf32d188183e057ec.svg?invert_in_darkmode\u0026sanitize=true\" align=middle width=31.607535299999988pt height=22.465723500000017pt/\u003e are the player’s and Opponent’s Kings respectively. \u003cimg src=\"/tex/55a049b8f161ae7cfeb0197d75aff967.svg?invert_in_darkmode\u0026sanitize=true\" align=middle width=9.86687624999999pt height=14.15524440000002pt/\u003e is the number of pieces on the board.\n\n### End Evaluation\n\n#### Sum of Distances\n\n\u003cimg src=\"/tex/68929b64645e6d7f6c50194224fea764.svg?invert_in_darkmode\u0026sanitize=true\" align=middle width=24.365003849999987pt height=22.465723500000017pt/\u003e = Distance of ith king of the player from jth King of the adversary.\n\n\u003cimg src=\"/tex/2dcc18a587457bfd193aaddbc8fdde0f.svg?invert_in_darkmode\u0026sanitize=true\" align=middle width=184.99128284999998pt height=31.75825949999999pt/\u003e\n\nwhere \u003cimg src=\"/tex/3c7e3568fa1625fede3ff436bfec732d.svg?invert_in_darkmode\u0026sanitize=true\" align=middle width=16.41942389999999pt height=14.15524440000002pt/\u003e is total number of kings of the player in the board and \u003cimg src=\"/tex/3ff44da77b122337fa0f84a268ccf932.svg?invert_in_darkmode\u0026sanitize=true\" align=middle width=16.41942389999999pt height=14.15524440000002pt/\u003e is total number of kings of the adversary in the board.\n\nMinimise \u003cimg src=\"/tex/6c315990d0571215c3ee124e84a53921.svg?invert_in_darkmode\u0026sanitize=true\" align=middle width=38.31442724999999pt height=14.15524440000002pt/\u003e if player has more number of pieces than adversary else maximise.\n\n#### Farthest Piece\n\n\u003cimg src=\"/tex/68929b64645e6d7f6c50194224fea764.svg?invert_in_darkmode\u0026sanitize=true\" align=middle width=24.365003849999987pt height=22.465723500000017pt/\u003e = Distance of ith King of player from jth King of the enemy.\n\n\u003cimg src=\"/tex/a0264dd532c39c450135dbf9adcaf5e5.svg?invert_in_darkmode\u0026sanitize=true\" align=middle width=286.8996504pt height=26.438629799999987pt/\u003e\n\nwhere \u003cimg src=\"/tex/3c7e3568fa1625fede3ff436bfec732d.svg?invert_in_darkmode\u0026sanitize=true\" align=middle width=16.41942389999999pt height=14.15524440000002pt/\u003e is total number of kings of the player in the board and \u003cimg src=\"/tex/3ff44da77b122337fa0f84a268ccf932.svg?invert_in_darkmode\u0026sanitize=true\" align=middle width=16.41942389999999pt height=14.15524440000002pt/\u003e is total number of kings of the adversary in the board.\n\nMinimise \u003cimg src=\"/tex/6c315990d0571215c3ee124e84a53921.svg?invert_in_darkmode\u0026sanitize=true\" align=middle width=38.31442724999999pt height=14.15524440000002pt/\u003e if player has more number of pieces than adversary else maximise.\n\n## How to run the code\n\nFirst install Requirements\n\n```\npip3 install -r requirements.txt\n```\n\n### Run the Game\n\n```bash\npython3 main.py\n```\n\n**You can tweak the parameters of the game bot from [main](main.py) file**\n\n## Conclusion\n\n1. Heuristics can be drastically improved by adding specific features.\n2. The depth of the game tree has a significant influence on the quality of the computer player.\n3. There's a tradeoff between calculation time and quality of the game.\n4. It is not efficient to use Minimax without optimizations while with them it can be a good solution.\n5. Alpha-Beta pruning is exponentially improving in comparison to Minimax as the depth grows.\n6. Certain heuristics are clearly better than others but some of the “bad” ones still work well in some cases.\n\n## References\n\n1. Two player draughts game template has been taken from [Pygame-Checkers](https://github.com/everestwitman/Pygame-Checkers/)\n\n## Contributing\n\nFound a bug? Create an **[issue](https://github.com/Hsankesara/Draughts-AI/issues/new)**.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhsankesara%2Fdraughts-ai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhsankesara%2Fdraughts-ai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhsankesara%2Fdraughts-ai/lists"}