{"id":22392354,"url":"https://github.com/maheshkumar-novice/chess","last_synced_at":"2026-05-18T05:38:18.562Z","repository":{"id":43416489,"uuid":"445781260","full_name":"Maheshkumar-novice/Chess","owner":"Maheshkumar-novice","description":"A command line game written in Ruby","archived":false,"fork":false,"pushed_at":"2022-03-02T15:58:36.000Z","size":1029,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-01T03:45:18.765Z","etag":null,"topics":["chess","colors","object-oriented-programming","rspec","rubocop","ruby","tests"],"latest_commit_sha":null,"homepage":"https://replit.com/@MaheshkumarP/Chess?lite=1\u0026outputonly=1","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/Maheshkumar-novice.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":"2022-01-08T09:52:20.000Z","updated_at":"2022-12-28T01:40:04.000Z","dependencies_parsed_at":"2022-08-26T00:15:40.142Z","dependency_job_id":null,"html_url":"https://github.com/Maheshkumar-novice/Chess","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Maheshkumar-novice%2FChess","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Maheshkumar-novice%2FChess/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Maheshkumar-novice%2FChess/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Maheshkumar-novice%2FChess/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Maheshkumar-novice","download_url":"https://codeload.github.com/Maheshkumar-novice/Chess/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245743436,"owners_count":20665093,"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":["chess","colors","object-oriented-programming","rspec","rubocop","ruby","tests"],"created_at":"2024-12-05T04:16:15.730Z","updated_at":"2026-05-18T05:38:13.528Z","avatar_url":"https://github.com/Maheshkumar-novice.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# [Chess](https://en.wikipedia.org/wiki/Chess)\n\nThis project is part of the [The Odin Project](https://www.theodinproject.com/paths/full-stack-ruby-on-rails/courses/ruby-programming/lessons/ruby-final-project)'s Ruby curriculum.\n\n\u003cdetails open=\"open\"\u003e\n  \u003csummary\u003eTable Of Contents\u003c/summary\u003e\n  \u003col\u003e\n    \u003cli\u003e\n      \u003ca href=\"#description\"\u003eDescription\u003c/a\u003e\n    \u003c/li\u003e\n    \u003cli\u003e\n      \u003ca href=\"#demo\"\u003eDemo\u003c/a\u003e\n    \u003c/li\u003e\n    \u003cli\u003e\n      \u003ca href=\"#built-with\"\u003eBuilt With\u003c/a\u003e\n    \u003c/li\u003e\n    \u003cli\u003e\n      \u003ca href=\"#try-yourself\"\u003eTry Yourself\u003c/a\u003e\n    \u003c/li\u003e\n    \u003cli\u003e\n      \u003ca href=\"#how-to-play\"\u003eHow To Play\u003c/a\u003e\n    \u003c/li\u003e\n    \u003cli\u003e\n      \u003ca href=\"#workflow\"\u003eWorkflow\u003c/a\u003e\n    \u003c/li\u003e\n    \u003cli\u003e\n      \u003ca href=\"#features\"\u003eFeatures\u003c/a\u003e\n    \u003c/li\u003e\n    \u003cli\u003e\n      \u003ca href=\"#implementation-details\"\u003eImplementation Details\u003c/a\u003e\n    \u003c/li\u003e\n    \u003cli\u003e\n      \u003ca href=\"#possible-enhancements\"\u003ePossible Enhancements\u003c/a\u003e\n    \u003c/li\u003e\n     \u003cli\u003e\n      \u003ca href=\"#what-i-learned\"\u003eWhat I Learned\u003c/a\u003e\n    \u003c/li\u003e\n     \u003cli\u003e\n      \u003ca href=\"#acknowledgements\"\u003eAcknowledgements\u003c/a\u003e\n    \u003c/li\u003e\n  \u003c/ol\u003e\n\u003c/details\u003e\n\n## Description\n\n### What is Chess?\nChess is a board game played between 2 players. More on Chess details [here](https://en.wikipedia.org/wiki/Chess).\n\n### Why did I create this?\nIt's the capstone project of The Odin Project's Ruby Programming course to practice and utilize what I learned throughout the course.\n\n### My experience\nIt's definitely a big project. I thought chess is a complicated game because I don't have much experience with chess before starting to work on this project. But after doing some research it clicked, it felt simple. Planning and Refactoring helped me stay in the right direction. I spent more time refactoring my code than writing the code. Honestly I enjoyed it. And here comes the important part, Tests. Without tests I can't imagine how I might approached this project. So overall I gained more experience in **Planning, Refactoring, Writing Unit Tests, Serialization, OOP concepts like SOLID, Inheritance, Composition, etc.**\n\n## Demo\n![Demo](./demo/demo.gif)\n\u003c/br\u003e\n  \n## Built With\n\n| Tool         | Use Case                |\n| ------------ | ----------------------- |\n| Ruby         | Programming Language    |\n| RSpec        | Unit Tests              |\n| Git \u0026 GitHub | Source Code Management  |\n\n## Try Yourself\n\n### Online\nYou can try in mobile also...\nHere's the [LINK](https://replit.com/@MaheshkumarP/Chess?lite=1\u0026outputonly=1) to try online.\n\n### Local\n\n#### Prerequisites\n```sh\nruby 3 - Recommended\nruby 2.7.4 or higher - Will work\n```\n\n#### Step 1: Clone the Repository\n```sh\ngit clone git@github.com:Maheshkumar-novice/chess.git\n```\n\n#### Step 2: Move to Chess Directory\n```sh\ncd chess\n```\n\n#### Step 3: Run the main ruby file\n```sh\nruby main.rb\n```\n\n#### Bonus: Pass Custom [FEN](https://www.chessprogramming.org/Forsyth-Edwards_Notation)\n```sh\nruby main.rb 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1'\n```\nThis will load the given FEN to create the game state.\n\n#### To Run the Test Suite\n\n#### Step 1: Install RSpec\n```sh\ngem install rspec\n```\n\n#### Step 2: Run the Test Suite\n```sh\nrspec\n```\n\n## How To Play\n\n### General Instructions\n* Run the game\n* Choose Mode\n* Create names if asked\n* Board will be shown\n* First prompt will ask you to choose a `source`, that is the cell of the piece you want to move\n* You can enter `cmd` in this step to enter `command` mode\n* Second prompt will ask you to choose a `destination`, that is the cell you want your piece to go\n\n### Command Mode\n* Available Commands: `draw`, `resign`, `save`, `fen`, `exit`\n* `draw` - It'll propose draw to your opponent after the completion of your current move\n* `resign` - It'll announce opponent as a winner\n* `save` - Save your current game, named as `your-name-vs-opponent-name-date-time.yml` format\n* `fen` - Shows the current FEN notation of the game\n* `exit` - Exits from the command mode to the game\n\n## Workflow\n\n### General\n* Research \u0026 Plan the feature by writing it down in a text editor\n* Implement the feature\n* Refactor\n* Write Tests\n* Refactor\n* If the game playable, test it by playing\n\n### Git\n* [Long Running Branches](https://git-scm.com/book/en/v2/Git-Branching-Branching-Workflows) workflow\n* `main` branch with most stable version\n* `dev` branch with new feature updates, partially stable, will be merged into `main` once become stable\n* `feature` branches to create new features and will be merged into `dev`\n\n## Features\n\n### Core\n* Basic movements and captures\n* Check\n* Checkmate\n* Stalemate\n* Castling\n* En Passant\n* Promotion\n\n### Additional\n* 50 move rule Draw\n* Manual Draw\n* Resignation\n* Command Mode\n* Save \u0026 Load games\n* Copy [FEN](https://www.chessprogramming.org/Forsyth-Edwards_Notation)\n* Load a FEN game of your wish by passing it as a command line argument\n\n### Others\n* Colorful UI\n* Mobile support\n\n## Possible Enhancements\n* Refactor Game class\n* Validator for FEN\n* 5 fold repetition Draw\n* Insufficient material Draw\n* Bot player improvement\n\n## Implementation Details\nBoard is inspired from the **Graph** data strucutre. Board holds 64 cell objects, where each cell object know who is their neighbour. It is, each cell object stores the location of their `row_right`, `row_left`, `column_above`, `column_below`, `top_left_diagonal`, `top_right_diagonal`, `bottom_right_diagonal`, `bottom_left_diagonal` neighbours.\n\n### Board\n* Hash with 64 pieces\n* **Key:** Symbol represent the cell coordinate (e.g. :a8)\n* **Value:** A cell object represents the board cell\n\n### Cell\n* Object that holds the piece\n* It stores the location of their neighbours\n```mermaid\nflowchart LR\ncell --- row_right\ncell --- row_left\ncell --- column_above\ncell --- column_below\ncell --- top_left_diagonal\ncell --- top_right_diagonal\ncell --- bottom_right_diagonal\ncell --- bottom_left_diagonal\n```\n\n### Check\nWhenever a player make a move their king shouldn't be in check.\n\n### Knight Move\nI designed knight's move as, one step forward in the four directions it can step and the diagonal moves related to that \nforward step.\nFor example, If the knight generate moves for it's left side,\n  * It can step on the left side\n  * It can go to either the top left diagonal or the bottom left diagonal\n\nThen we use other objects to operate and manipulate this board and the pieces in the cells to play the game of chess.\n\n## What I Learned\n* Importance of Refactoring\n* Importance of Planning\n* Importance of Tests\n* SOLID priniciples of OOP\n* More about Composition\n* More about Inheritance\n* And more....\n  \n## Acknowledgements\n* [The Odin Project](https://theodinproject.com)\n* [Lichess](https://lichess.org)\n* [Chess.com](https://chess.com)\n* [Replit](https://replit.com)\n* [Wikipedia](https://wikipedia.org)\n* [Chess Variants](http://www.chessvariants.org/d.chess/chess.html)\n* [Chess Programming](https://www.chessprogramming.org/Forsyth-Edwards_Notation)\n\nFound an issue? [Click](https://github.com/Maheshkumar-novice/Chess/issues) here to raise an issue.\n\n[Move To Top](#chess)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaheshkumar-novice%2Fchess","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaheshkumar-novice%2Fchess","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaheshkumar-novice%2Fchess/lists"}