{"id":15293328,"url":"https://github.com/devluxor/sapphire-chess","last_synced_at":"2025-09-13T08:47:38.778Z","repository":{"id":62658531,"uuid":"551957836","full_name":"devluxor/sapphire-chess","owner":"devluxor","description":"Sapphire Chess is a Chess engine, entirely written from scratch. It has complete game rules, an algebraic input systen, and a functional AI. It provides three game modes: Human vs. Human, Human vs. AI, and AI vs. AI. It also comes with an optional UI.","archived":false,"fork":false,"pushed_at":"2024-10-03T10:25:13.000Z","size":356,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-29T22:39:15.787Z","etag":null,"topics":["ai","chess","chess-board","chess-engine","minimax-algorithm","minimax-alpha-beta-pruning","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/devluxor.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2022-10-15T13:37:51.000Z","updated_at":"2025-07-19T11:56:06.000Z","dependencies_parsed_at":"2024-12-02T02:37:16.995Z","dependency_job_id":null,"html_url":"https://github.com/devluxor/sapphire-chess","commit_stats":null,"previous_names":["lux0rdev/sapphire-chess","devluxor/sapphire-chess","lucsorr/sapphire-chess"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/devluxor/sapphire-chess","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devluxor%2Fsapphire-chess","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devluxor%2Fsapphire-chess/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devluxor%2Fsapphire-chess/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devluxor%2Fsapphire-chess/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devluxor","download_url":"https://codeload.github.com/devluxor/sapphire-chess/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devluxor%2Fsapphire-chess/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274941629,"owners_count":25378204,"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-09-13T02:00:10.085Z","response_time":70,"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","chess","chess-board","chess-engine","minimax-algorithm","minimax-alpha-beta-pruning","ruby"],"created_at":"2024-09-30T16:46:19.544Z","updated_at":"2025-09-13T08:47:38.576Z","avatar_url":"https://github.com/devluxor.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sapphire Chess\n\n[![Gem Version](https://badge.fury.io/rb/sapphire-chess.svg)](https://badge.fury.io/rb/sapphire-chess)\n\nSapphire Chess is a command line-based chess game with an algebraic notation input system,\ncomplete chess rules, a beautiful interface and a functional AI. It provides three game modes: \nHuman vs. Human, Human vs. AI, and AI vs. AI.\n\nPlease, visit \u003chttps://medium.com/@lucas.sorribes/nostromo-my-ruby-chess-journey-part-i-7ef544b547a5\u003e for a very detailed account of how I wrote this game.\n\nSupported Rubies: 3.1, 3.0, 2.7.\n\nThe game has not been tested on older versions, but it might still work.\n\nPlaying within the VS Code terminal is highly recommended because it renders the icons better.\n\n---\n\n## Current Features\n\n* A beautiful board with easy-to-distinguish colors for white and black pieces.\n* Fully functional AI\n* Three levels of difficulty.\n* Three game modes: human vs. computer, human vs. human.\n* Full chess movement rules implementation, including castling and *en passant*, for both the human and the computer player.\n* Accepts algebraic notation for movements, with human input validation.\n* Material score display.\n* Player's last move display.\n\n## Easy Setup (run containerized version; with Docker)\n\nSimply, build the image (it's very lightweight) with:\n\n```sh\ndocker build -t sapphire-chess .\n```\n\nAnd run it with:\n\n```sh\ndocker run -it sapphire-chess\n```\n\n## Setup\n\nInstall with:\n\n```ruby\ngem install 'saphhire-chess'\n```\n\nAnd execute from the command prompt with:\n\n```sh\nsapphire-chess\n```\n\nCurrently, the icons are only loaded properly from within VS Code terminals, so, for the moment, I highly recommend executing this command from there.\n\nYou can also create a new `.rb` file with this content and execute it:\n\n```ruby\nrequire 'sapphire-chess'\n\nEngine.new.play\n```\n\n## Difficulty Mode\n\nThe difficulty mode is based on how many turns the computer can think ahead (the depth of the tree generated by `AI#minimax`, max. 3), the aggressiveness of the pieces, and the enemy's carelessness.\n\nMy recommendation is to play the game on the *hard* mode, as this was the original intention when I designed it. I introduced the other difficulties based on the suggestions from those who weren't able to beat the machine. However, the hard mode, due to the current Minimax implementation, is a little slow; I'm working on ways to improve the performance of this method.\n\n## Screenshot\n\n![Game screenshot](https://live.staticflickr.com/65535/52630422741_bc858d0096_z.jpg)\n\n## The AI\n\nThe AI is based on a Minimax algorithm with Alpha-Beta pruning. This algorithm generates possible outcomes (*children*) for a provisional move: Each branch represents the enemy's possible move in the next turn as an answer to the provisional move; (i.e.: if current player is white [the maximizing player], it generates every possible movement for the next player, black [the minimizing player], who will choose the best possible move, and so on. \n\nThe best (relative to each player) possible outcome for each move will determine what move is chosen) The Alpha-Beta 'prunes' the tree: it makes the search more efficient, removing unnecessary branches, resulting in a faster process.\n\nLucas Sorribes, released under the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevluxor%2Fsapphire-chess","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevluxor%2Fsapphire-chess","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevluxor%2Fsapphire-chess/lists"}