{"id":17978788,"url":"https://github.com/jon-becker/pleonexia","last_synced_at":"2025-04-04T00:25:24.787Z","repository":{"id":117247319,"uuid":"406526313","full_name":"Jon-Becker/pleonexia","owner":"Jon-Becker","description":"A simple chess AI coded using minimax, material counting, and positional values.","archived":false,"fork":false,"pushed_at":"2021-09-28T21:58:19.000Z","size":4367,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-02T09:47:09.750Z","etag":null,"topics":["alpha-beta-pruning","artificial-intelligence","chess","chess-ai","minimax"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/Jon-Becker.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":"2021-09-14T21:28:53.000Z","updated_at":"2021-11-03T18:48:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"ba180345-2d1c-4e28-81f8-b03ea978cad1","html_url":"https://github.com/Jon-Becker/pleonexia","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/Jon-Becker%2Fpleonexia","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jon-Becker%2Fpleonexia/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jon-Becker%2Fpleonexia/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jon-Becker%2Fpleonexia/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Jon-Becker","download_url":"https://codeload.github.com/Jon-Becker/pleonexia/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247099871,"owners_count":20883479,"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":["alpha-beta-pruning","artificial-intelligence","chess","chess-ai","minimax"],"created_at":"2024-10-29T17:35:09.278Z","updated_at":"2025-04-04T00:25:24.766Z","avatar_url":"https://github.com/Jon-Becker.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# pleonexia\nPleonexia is a minimax based chess engine that calculates the best move for the machine to make by material counting as well as positional scoring.\nYou can [View The Demo](https://jbecker.dev/demos/pleonexia) here.\n\n## How it works\nPleonexia utilizes the popular minimax method to search for and calculate ideal moves within two-player games such as chess. In order to reduce the amount of total calculations, we also implement aplha-beta pruning which removes possibilities if they result in worse positions that previously calculated moves.\n\n- We start off by creating a chess.js `Chess` object which we will use for the duration of the game for calculations, moves, and more.\n- The `Chess` object has many useful methods, such a `Chess.moves()` which lists all possible moves found for the current position for that player.\n- To begin calculating, we wait for it to be our turn within the `updateGame()` function which interacts with Chessboard.js's frontend to take in plays from the player. This function calls `make_best_move(depth, game)` after checking that the game is not over, with `depth` being the amount of moves to calculate ahead, and `game` being the current `Chess` object.\n- `make_best_move` makes a call to `get_best_move()`, which is just a simple wrapper that begins a timer, counter, and handles other statistics before making a call to our minimax functions.\n- The minimax functions loop through the array of possible moves from `Chess.moves()`, giving each a score using `minimum` and `maximum`, with `minimum` being the minimum score for the AI if it plays this line, and `maximum` being the maximum player score if the AI chooses this line. \n  - Within chess, scores are calculated using material values, pawns being 1, bishops and knights being 3, rooks being 5, and the queen being 8.\n  - Our calculations use these basic ratios but also include a 0.5 score bonus if the player has both bishops remaining, since having both bishops is more powerful than having both knights.\n  - In addition to these material scores, we also give each piece additional value based on which of the 64 squares it resides on. Chess is a game about control, so the AI will try to prioritize controlling and keeping control of the center, giving these squares more weight for pieces like pawns, bishops, and knights.\n  - The AI is incentivized to avoid checkmate and find checkmates by giving lines that end up in checkmate a massive score boost. This also helps us avoid ending up in checkmate.\n- Each call to `minimax` calls a scoring function which returns the total difference in score for both white and black, with negative scores being worse than positive scores. \n- `minimax` will continue to call itself, saving the highest `minimum` and `maximum` until it runs out of possibile moves for the `depth` provided. If a move line results in a worse `minimum` or `maximum` than we currently have stored, we will skip calculations for that line to save time.\n- `minimax` returns the move, and we make it using `Chess.move(move)`.\n- The game continues until a draw or checkmate is reached.\n\n## Statistics \u0026 Specifications\n- Default depth: `3`\n  - This parameter can be edited on line 299 within the `updateGame()` function.\n- Lichess Winrate: `40.39%`\n  - A lichess bot is currently running and playing 2 games concurrently with a depth of 3. Since we are only material counting, its not a very good AI.\n- AES: `~3100 Evaluations per Second`\n\n### Credits\nThis project is completely coded by [Jonathan Becker](https://jbecker.dev), using [Bootstrap](https://getbootstrap.com) \u0026 [Chessboard.js](https://chessboardjs.com/) for the frontend, with [Chess.js](https://github.com/jhlywa/chess.js/blob/master/README.md) powering the basic chess functionality.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjon-becker%2Fpleonexia","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjon-becker%2Fpleonexia","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjon-becker%2Fpleonexia/lists"}