{"id":19543341,"url":"https://github.com/jonathanyiv/tic-tac-toe","last_synced_at":"2025-10-08T08:48:43.919Z","repository":{"id":87536104,"uuid":"99504143","full_name":"JonathanYiv/tic-tac-toe","owner":"JonathanYiv","description":"Implementation of Tic-Tac-Toe in Ruby","archived":false,"fork":false,"pushed_at":"2017-09-09T05:42:47.000Z","size":43,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-08T19:11:35.696Z","etag":null,"topics":["ruby","tic-tac-toe"],"latest_commit_sha":null,"homepage":"https://repl.it/@JonathanYiv/Tic-Tac-Toe","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/JonathanYiv.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-06T17:59:53.000Z","updated_at":"2017-11-13T08:20:11.000Z","dependencies_parsed_at":"2023-05-10T12:31:52.243Z","dependency_job_id":null,"html_url":"https://github.com/JonathanYiv/tic-tac-toe","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/JonathanYiv%2Ftic-tac-toe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JonathanYiv%2Ftic-tac-toe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JonathanYiv%2Ftic-tac-toe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JonathanYiv%2Ftic-tac-toe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JonathanYiv","download_url":"https://codeload.github.com/JonathanYiv/tic-tac-toe/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240798355,"owners_count":19859348,"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":["ruby","tic-tac-toe"],"created_at":"2024-11-11T03:18:24.045Z","updated_at":"2025-10-08T08:48:38.890Z","avatar_url":"https://github.com/JonathanYiv.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tic-Tac-Toe Project\n\nCheck out my command line version of the game [Tic-Tac-Toe](https://en.wikipedia.org/wiki/Tic-tac-toe) built with Ruby!\n\nThis is a project from [The Odin Project](https://www.theodinproject.com/courses/ruby-programming/lessons/oop).\n\n![Tic-Tac-Toe](tictactoe.png)\n\n## Installation\nOpen your Terminal/Command Line. Navigate to the directory where your version will live. Type in the following:\n```\n$ git clone https://github.com/JonathanYiv/tic-tac-toe.git\n$ cd tic-tac-toe\n$ ruby lib/game.rb\n```\n\n## Pre-Project Thoughts\n\nThe structure of the project should be something like:\n```\nClass Tic-Tac-Toe\n  Class GameBoard\n\t\tinitialize method that creates two players\n\t\tdisplay method that uses the @instancevariables to help display, checks for win conditions\n\t\t9 @instancevariables for each position\n\t\tchange method that lets the player change an @instance variable\n\t\twinning method that is called by the display method if win conditions are met, displays the victory board, tells players the game is done (by setting their turn boolean to false)\n  Class Player\n\t\tinitialize method that prompts the player for their name\n\t\t@instancevariable regarding whether it is the player's turn\n\t\t@@classvariable to track the number of players\n ```\n\n## Post-Project Thoughts\n1. I should separate the classes into different files for best practices, then call them in using the require keyword.\n\n2. I feel like having the instance variable for whose turn it is inside of the class Mastermind added too much dependency between classes. I should have had each Player instance be able to hold a boolean for whether it is their turn or not.\n3. I'm quite proud that the game can filter for incorrect input and reprompt you accordingly.\n\n4. I wish there was a more elegant way to code for the solutions. I read about [magic squares](http://mathworld.wolfram.com/MagicSquare.html) where any row/column/diagonal will always sum to the same amount, so I thought assigning values to each component in the array and checking for the sum would have been possible. However, I believe that level of complexity is beyond the scope of this project.\n\n5. I may one day include an AI that uses the optimal tic-tac-toe strategy shown in the below image from Wikipedia.\n\n![Optimal TicTacToe](https://upload.wikimedia.org/wikipedia/commons/thumb/d/de/Tictactoe-X.svg/220px-Tictactoe-X.svg.png)\n\n6. Through feedback provided from some [fellow Odinites](https://gitter.im/TheOdinProject/theodinproject), I modified my project to only initialize variables in the initialize method and separated a few methods into smaller methods. Previously, I had output and input statements in my initialize method and had a few larger methods doing too many things, all of which are poor practice.\n\n7. @benjaminpetersen found an error where after an incorrect input, it no longer took capitalized letters. This was easily solved by adding #downcase to a variable.\n\n8. In this [Odin Follow-Up Project](https://www.theodinproject.com/courses/ruby-programming/lessons/testing-ruby):\n\n\t1. I implemented a test suite for tic-tac-toe. This helped solidify some of the lessons I learned from writing this script: I should have separated the classes and reduced method dependency. I made a few changes accordingly that helped push the project in that direction.\n\n\t2. Following the last [follow-up project](https://github.com/JonathanYiv/enumerable_methods) where I integrated a test suite, I reflected on mocks/stubs being out of my comfort zone. I implemented a simple mock/stub in this test suite (although it is not related to the program) so I at least understand the syntax. After doing some reading, it appears that it is easy to misuse mocks in a way that make your tests poorly designed. A general rule of thumb is that if your testing needs a complicated object/interface as a parameter, and it would be a pain to just instantiate the object/interface, just use a mock. Going forward, I will definitely integrate unit and integration tests into my workflow, and experiment with mocks/stubs accordingly.\n\n\t3. This [first answer on StackOverflow](https://stackoverflow.com/questions/4904096/whats-the-difference-between-unit-functional-acceptance-and-integration-test) helped illuminate the different types of tests for me.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonathanyiv%2Ftic-tac-toe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonathanyiv%2Ftic-tac-toe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonathanyiv%2Ftic-tac-toe/lists"}