{"id":19506878,"url":"https://github.com/afsalthaj/tic-tac-toe","last_synced_at":"2025-10-06T18:33:54.341Z","repository":{"id":80596611,"uuid":"99867632","full_name":"afsalthaj/tic-tac-toe","owner":"afsalthaj","description":null,"archived":false,"fork":false,"pushed_at":"2017-09-21T12:15:11.000Z","size":71,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-26T02:51:03.916Z","etag":null,"topics":["minimax-algorithm","object-oriented","ruby","tictactoe-game"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/afsalthaj.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2017-08-10T01:29:36.000Z","updated_at":"2017-08-27T05:13:58.000Z","dependencies_parsed_at":"2023-06-26T22:20:08.286Z","dependency_job_id":null,"html_url":"https://github.com/afsalthaj/tic-tac-toe","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/afsalthaj/tic-tac-toe","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afsalthaj%2Ftic-tac-toe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afsalthaj%2Ftic-tac-toe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afsalthaj%2Ftic-tac-toe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afsalthaj%2Ftic-tac-toe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/afsalthaj","download_url":"https://codeload.github.com/afsalthaj/tic-tac-toe/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afsalthaj%2Ftic-tac-toe/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278658529,"owners_count":26023673,"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-10-06T02:00:05.630Z","response_time":65,"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":["minimax-algorithm","object-oriented","ruby","tictactoe-game"],"created_at":"2024-11-10T22:38:48.769Z","updated_at":"2025-10-06T18:33:54.308Z","avatar_url":"https://github.com/afsalthaj.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# My Tic-Tac-Toe in Ruby\n\nThis is a tic-tac-toe with a command line interface \nthat lets you play a tic-tac-toe with the computer.\n\nThe implementation is done in Ruby using the min-max algorithm.\n\n# Start playing\n* Install Ruby (Ex: In Mac, brew install ruby)\n* Clone the project \n\n```\n\ngit clone https://github.com/afsalthaj/tic-tac-toe\n\n```\n* Play game\n\n```\ncd tic-tac-toe\ncd ui\nruby command_line_game.rb\n\n```\n\n# Strategy\n* Computer plays all the future games the moment you start the game.\n* Computer ranks all the moves, and depending the player, it choose the move\nwith either the maximum score, or minimum score. Maximum score if next move is \"Computer's\"\nelse minimum.\n* The computer player is hard-coded as :X and the user is identified as :O\n\n## Pros \n* Minimax algorithm, from a high level perspective, is fairly intuitive \n* It is always interesting to build a recursive algorithm.\n* Less code.\n\n## Cons\n* Relatively a complex recursion once developed.\n* First stage computations taking time. Depth factor can be incorporated.\n\n# Game Runner\nGame Runner is sort of a client of Tic tac toe `Game` that makes use\nof the strategy and the game. \nGame class is responsible for keeping track of the state of the game.\nObviously state of the game is represented by the player, the board and the \ncomplete set of moves available at a point in time.\n\n# Test Coverage\n* All that I did here is, simulating a game in test case, and asserting each moves/possible moves.\n* Asserting each move/possible move is done intuitively and did't focus much on min-max algorithm.\n* File \"game.rb\" and \"game_runner.rb\" are the ones tested. File \"play.rb\" is just invoking the game.\n\nRun tests by:\n\n```shell\n\n// In the root directory\n\n// Optional command\nbrew install ruby\nbundle install\n\n//run tests\nruby spec.rb\n\n// get the coverage report\ncd coverage\nopen index.html\n\n```\n# Todo:\n* It seems the algorithm selected is quite advanced, and is not scalable.\n* The first iteration of every game starts in 20 seconds, which is not so good.\n* The first selection of player carried over to the rest of the games. This is to be made flexible\n* Mock command line input output testing rspec\n\n# Reference\n* https://www.quora.com/Is-there-a-simple-explanation-of-a-minimax-algorithm \n* https://www.youtube.com/watch?v=zDskcx8FStA\n* https://en.wikipedia.org/wiki/Minimax","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fafsalthaj%2Ftic-tac-toe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fafsalthaj%2Ftic-tac-toe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fafsalthaj%2Ftic-tac-toe/lists"}