{"id":19723019,"url":"https://github.com/davidadsp/chess-trap-scorer","last_synced_at":"2025-04-29T22:30:50.496Z","repository":{"id":46376792,"uuid":"417305315","full_name":"davidADSP/chess-trap-scorer","owner":"davidADSP","description":"A Python codebase for scoring trappy chess openings","archived":false,"fork":false,"pushed_at":"2021-10-19T01:08:32.000Z","size":879,"stargazers_count":51,"open_issues_count":2,"forks_count":6,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-05T19:51:16.520Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","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/davidADSP.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}},"created_at":"2021-10-14T22:58:26.000Z","updated_at":"2025-01-14T20:45:20.000Z","dependencies_parsed_at":"2022-09-22T07:47:34.756Z","dependency_job_id":null,"html_url":"https://github.com/davidADSP/chess-trap-scorer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidADSP%2Fchess-trap-scorer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidADSP%2Fchess-trap-scorer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidADSP%2Fchess-trap-scorer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidADSP%2Fchess-trap-scorer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davidADSP","download_url":"https://codeload.github.com/davidADSP/chess-trap-scorer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251592936,"owners_count":21614445,"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","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":[],"created_at":"2024-11-11T23:19:15.484Z","updated_at":"2025-04-29T22:30:50.072Z","avatar_url":"https://github.com/davidADSP.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- PROJECT SHIELDS --\u003e\n[![Contributors][contributors-shield]][contributors-url]\n[![Forks][forks-shield]][forks-url]\n[![Stargazers][stars-shield]][stars-url]\n[![Issues][issues-shield]][issues-url]\n[![MIT License][license-shield]][license-url]\n[![LinkedIn][linkedin-shield]][linkedin-url]\n\n\u003c!-- PROJECT LOGO --\u003e\n\u003cbr /\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/davidADSP/chess-trap-scorer\"\u003e\n    \u003cimg src=\"images/chesstrapscorer.png\" alt=\"Logo\" height=\"120\"\u003e\n  \u003c/a\u003e\n\n  \u003cp align=\"center\"\u003e\n    Chess Trap Scorer\n    \u003c!-- \u003cbr /\u003e --\u003e\n    \u003c!-- \u003ca href=\"https://github.com/davidADSP/chess-trap-scorer\"\u003e\u003cstrong\u003eExplore the docs »\u003c/strong\u003e\u003c/a\u003e --\u003e\n    \u003cbr /\u003e\n    \u003c!-- \u003ca href=\"https://github.com/davidADSP/chess-trap-scorer\"\u003eView Demo\u003c/a\u003e --\u003e\n    ·\n    \u003ca href=\"https://github.com/davidADSP/chess-trap-scorer/issues\"\u003eReport Bug\u003c/a\u003e\n    ·\n    \u003ca href=\"https://github.com/davidADSP/chess-trap-scorer/issues\"\u003eRequest Feature\u003c/a\u003e\n  \u003c/p\u003e\n\u003c/p\u003e\n\u003cbr\u003e\n\n\n\u003c!-- TABLE OF CONTENTS --\u003e\n\n\u003csummary\u003e\u003ch2 style=\"display: inline-block\"\u003eTable of Contents\u003c/h2\u003e\u003c/summary\u003e\n\u003col\u003e\n  \u003cli\u003e\n    \u003ca href=\"#about-the-project\"\u003eAbout The Project\u003c/a\u003e\n  \u003c/li\u003e\n  \u003cli\u003e\n    \u003ca href=\"#getting-started\"\u003eGetting Started\u003c/a\u003e\n  \u003c/li\u003e\n  \u003cli\u003e\u003ca href=\"#license\"\u003eLicense\u003c/a\u003e\u003c/li\u003e\n  \u003cli\u003e\u003ca href=\"#contact\"\u003eContact\u003c/a\u003e\u003c/li\u003e\n  \u003cli\u003e\u003ca href=\"#acknowledgements\"\u003eAcknowledgements\u003c/a\u003e\u003c/li\u003e\n\u003c/ol\u003e\n\n\n\n\u003cbr\u003e\n\n---\n\u003c!-- ABOUT THE PROJECT --\u003e\n## About The Project\n\n\u003cimg src=\"images/example.png\" alt=\"Stafford Gambit\" width='100%'\u003e\n\nThis project allows you to score trappy chess openings, based on two factors:\n\n🎲  \u003cb\u003eProbability\u003c/b\u003e\n\nHow likely is the player to play the next move in the trap sequence?\n\nA good trap should have a high likelihood that the next move in sequence is commonly chosen.\n\n😵  \u003cb\u003ePotency\u003c/b\u003e\n\nHow likely is the player to lose after they have fallen into the trap?\n\nA good trap should be deadly once your opponent has fallen into it!\n\n---\n\n🎯 \u003cb\u003eTrap score\u003c/b\u003e\n\nThe trap score for a given pgn input is the product of these two scores.\n\nFor more information, see the accompanying [blog post](https://adsp.ai/articles/chess-trap-scorer/).\n\nHave fun!\n\n---\n\u003c!-- GETTING STARTED --\u003e\n\n## Getting Started\n\nTo get a local copy up and running, follow these simple steps.\n\n\n\u003c!-- INSTALLATION --\u003e\n### Installation\n\n1. Clone the repo\n   ```sh\n   git clone https://github.com/davidADSP/chess-trap-scorer.git\n   cd chess-trap-scorer\n   ```\n2. Pip install requirements (inside a virtual environment)\n   ```sh\n   pip install -r requirements.txt\n   ```\n\n\u003c!-- QUICKSTART --\u003e\n### Quickstart\n\nTo score a given opening, simply use the following command, with the pgn of your choice.\n\n   ```sh\n   python3 solver.py --pgn '1. e4 e5 2. Nf3 Nf6 3. Nxe5 Nc6 4. Nxc6 dxc6 5. d3 Bc5 6. Bg5'\n   ```\n\nThe [lichess opening API](https://lichess.org/api) is used to gather data for the analysis. No token is required.\n\nThe `config.py` file allows you to change the variant, speeds and rating range of the analysis, as well as the number of moves to search over to find the best follow up move and the alpha of the potency confidence interval.\n\n\n### Output\n\nThe output is the following summary (shown here with descriptive labels):\n\n```\nBlack to play \u003c- The colour of the player who will take advantage of the trap\nTotal moves:\t 6 \u003c- Number of moves played by the opponent\n\te4:\t        64.02% \u003c- The likelihood that the opponent plays this required move\n\tNf3:\t    66.17%\n\tNxe5:\t    34.16%\n\tNxc6:\t    84.17%\n\td3:\t        38.70%\n\tBg5:\t    14.63%\nLikelihood:\t    0.69% \u003c- The product of the likelihoods\nFrequency:\t    Every 145 games \u003c- 1 / likelihood\nAv Move Prob:   43.63% \u003c- Geometric mean of the move probabilities\n\nContinuation:\tNxe4 \u003c- Best move that takes advantage of the trap\nTotal games:\t1670 \u003c- Number of lichess games where this move has been played\nShock:\t\t    +43.21% (52.42% -\u003e 95.63%) \u003c- The delta of the win likelihood before and after this move\nPotency:\t    95.63% CI ['94.65%', '96.61%'] (95%) \u003c- The % chance of winning after this move with confdience interval\n\nTrap Score:\t\t    41.72% ( = 43.63% * 95.63% ) \u003c- the product of the Av Move Prob and Potency\n```\n\nThe higher the trap score, the better the trap!\n\n### Jupyter notebook\n\nA jupyter notebook `traps.ipynb` is also provided, where a view of the board is also rendered.\n\n---\n\u003c!-- LICENSE --\u003e\n## License\n\nDistributed under the MIT License. See `LICENSE` for more information.\n\n---\n\u003c!-- CONTACT --\u003e\n## Contact\n\nDavid Foster - [@davidADSP](https://twitter.com/davidADSP) - david@adsp.ai\n\nProject Link: [https://github.com/davidADSP/chess-trap-scorer](https://github.com/davidADSP/chess-trap-scorer)\n\n\n---\n\u003c!-- ACKNOWLEDGEMENTS --\u003e\n## Acknowledgements\n\nThanks to all the great chess content creators out there - here's three of the best:\n\n* [GothamChess](https://www.youtube.com/channel/UCQHX6ViZmPsWiYSFAyS0a3Q)\n* [Agadmator](https://www.youtube.com/c/AGADMATOR)\n* [Eric Rosen](https://www.youtube.com/user/RosenChess)\n\n---\n\u003c!-- MARKDOWN LINKS \u0026 IMAGES --\u003e\n\u003c!-- https://www.markdownguide.org/basic-syntax/#reference-style-links --\u003e\n[contributors-shield]: https://img.shields.io/github/contributors/davidADSP/chess-trap-scorer.svg?style=for-the-badge\n[contributors-url]: https://github.com/davidADSP/chess-trap-scorer/graphs/contributors\n[forks-shield]: https://img.shields.io/github/forks/davidADSP/chess-trap-scorer.svg?style=for-the-badge\n[forks-url]: https://github.com/davidADSP/chess-trap-scorer/network/members\n[stars-shield]: https://img.shields.io/github/stars/davidADSP/chess-trap-scorer.svg?style=for-the-badge\n[stars-url]: https://github.com/davidADSP/chess-trap-scorer/stargazers\n[issues-shield]: https://img.shields.io/github/issues/davidADSP/chess-trap-scorer.svg?style=for-the-badge\n[issues-url]: https://github.com/davidADSP/chess-trap-scorer/issues\n[license-shield]: https://img.shields.io/github/license/davidADSP/chess-trap-scorer.svg?style=for-the-badge\n[license-url]: https://github.com/davidADSP/chess-trap-scorer/blob/main/LICENSE\n[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge\u0026logo=linkedin\u0026colorB=555\n[linkedin-url]: https://linkedin.com/in/davidtfoster","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidadsp%2Fchess-trap-scorer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavidadsp%2Fchess-trap-scorer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidadsp%2Fchess-trap-scorer/lists"}