{"id":19543380,"url":"https://github.com/jonathanyiv/connect_four","last_synced_at":"2025-10-11T07:12:15.704Z","repository":{"id":87535977,"uuid":"101577476","full_name":"JonathanYiv/connect_four","owner":"JonathanYiv","description":"Implementation of Connect Four in Ruby","archived":false,"fork":false,"pushed_at":"2017-10-01T06:29:40.000Z","size":90,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-26T05:33:25.006Z","etag":null,"topics":["connect-four","ruby"],"latest_commit_sha":null,"homepage":"https://repl.it/@JonathanYiv/Connect-Four","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-27T20:11:34.000Z","updated_at":"2017-11-13T08:19:41.000Z","dependencies_parsed_at":"2023-05-10T12:31:37.421Z","dependency_job_id":null,"html_url":"https://github.com/JonathanYiv/connect_four","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/JonathanYiv/connect_four","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JonathanYiv%2Fconnect_four","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JonathanYiv%2Fconnect_four/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JonathanYiv%2Fconnect_four/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JonathanYiv%2Fconnect_four/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JonathanYiv","download_url":"https://codeload.github.com/JonathanYiv/connect_four/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JonathanYiv%2Fconnect_four/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279006585,"owners_count":26084129,"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-11T02:00:06.511Z","response_time":55,"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":["connect-four","ruby"],"created_at":"2024-11-11T03:18:32.951Z","updated_at":"2025-10-11T07:12:15.659Z","avatar_url":"https://github.com/JonathanYiv.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Connect Four Project\n\nThe goal of this project is to implement [Connect Four](https://en.wikipedia.org/wiki/Connect_Four) using Ruby and [TDD (Test-Driven Development)](https://en.wikipedia.org/wiki/Test-driven_development).\n\nTest-Driven Development follows this cycle:\n\n1. Add a Test\n\n2. Run all Tests -- the new Test should Fail\n\n3. Write the Code for the Test to Pass\n\n4. Run Tests\n\n5. Refactor\n\n6. Repeat\n\nThis is a project from [The Odin Project](https://www.theodinproject.com/courses/ruby-programming/lessons/testing-ruby).\n\n![Connect Four](./connect_four.png)\n\n## Installation\n\nOpen your Terminal/Command Line. Navigate to the directory where your version will live. Type in the following:\n\n```\n$ git clone https://github.com/JonathanYiv/connect_four.git\n$ cd connect_four\n$ ruby lib/game.rb\n```\n\n## Pre-Project Thoughts\n\nThis will be my first project that I tackle TDD-style. \nThe only thing that I think will be slightly challenging to implement will be checking for win conditions since there are so many permutations.\nI somehow have to use a search function to look at all nearby nodes for an inserted 'disc', and for all nearby nodes that are of equal value, search in the same direction to see if there are four in a row.\n\n### Project Structure\n\n```ruby\n# gameboard.rb ✓\nclass GameBoard ✓\n\tinstance variables: ✓\n\t\t@board: is an array of column arrays ✓\n\t\t@player1 ✓\n\t\t@player2 ✓\n\t\t@player_turn: will be 1 or 2 ✓\n\tmethods: ✓\n\t\tplay: displays the title, @board, and instructions \n\t\t\ttitle: displays an ASCII art title ✓\n\t\t\tdisplay: displays @board in the shape of a Connect Four game ✓\n\t\t\tinstructions: displays the game instructions \n\t\t\tturns: starts a loop that changes @player_turn value every turn and checks for win scenario\n\t\t\t\tturn: has @player1/@player2 take_turn and add_disc to @board\n\t\t\t\t\tadd_disc: adds a value to the 'bottom' of the column array in the appropriate @board array\n\t\t\t\tcheck_for_win: checks for win scenarios, for every added disc, it will check all discs at distance = 1 if they are the same, if so:\n\t\t\t\t\t\t\t   it will check in the same direction to see if there are 4 in a row, if so, win conditions are met\n\t\t\twin: displays winning text\n\n# player.rb ✓\nclass Player ✓\n\tinstance variables: ✓\n\t\t@name: player name ✓\n\tmethods: ✓\n\t\ttake_turn: gets input to pass to GameBoard.add_disc \n\n# game.rb ✓\n# requires gameboard and player classes ✓\n# asks for player names ✓\n# then starts the game \n```\n\n## Post-Project Thoughts\n\n1. As I created tests, I ran into the issue of properly testing File IO. After evaluation and feedback from the Odin Chat, it appears that you simply wouldn't test the IO. You would just test the behavior/interface and not the implementation. Now, for the purposes of this exercise, they mandated that anything I code must have a test for it, so... I will do it for the sake of practice but I understand the reality going forward. Update (Several Hours Later): I will not test IO. Testing input and output and sanitizing input is just.. ridiculously complex and annoying for the scope of this project.\n\n2. Furthermore, @KevinMulhern helped me understand that testing particular implementation details makes the tests brittle as opposed to testing behavior.\n\n3. This was one of the more frustrating projects because I already had the layout for the entire program made, and just needed to implement it. Changing my mindset towards making tests first was and still is inhibiting on productivity, although I can understand why it is beneficial in the long term. Since this project asked me to test every single thing meticulously, I learned that there are some things that are definitely meant to be tested or are not worth testing. I will not test those things in the future, but I will try to integrate TDD into my development workflow. Sigh.\n\n4. After some investigation, apparently a [Psuedo-Terminal](https://ruby-doc.org/stdlib-2.2.3/libdoc/pty/rdoc/PTY.html) might have sufficed for testing IO. I feel this is too complicated for my current level.\n\n5. There do not appear to be very many up to date resources on RSpec. Here's a brief overview with rankings from my best to worst:\n\n\t1. RubyPigeon's [Core](http://www.rubypigeon.com/posts/rspec-core-cheat-sheet/) and [Expectations](http://www.rubypigeon.com/posts/rspec-expectations-cheat-sheet/) cheat sheets are fantastic.\n\n\t2. [Semaphore's Learn RSpec](https://semaphoreci.com/community/series/learn-rspec) series is also great.\n\n\t3. The [official documentation](http://rspec.info/documentation/) and [Relish documentation](https://relishapp.com/rspec) while useful and informative, aren't really beginner friendly. \n\n\t4. One of the maintainer's 2 hour [Screencast Course on PluralSight](https://www.pluralsight.com/courses/rspec-ruby-application-testing) is very informative, but it's not well-suited for beginners and doesn't really fill in my gaps of knowledge for HOW and WHAT to test in an easy-to-understand way. (To be fair, the course description does say that it is recommended for intermediate level programmers, so I was in over my head.)\n\n\t5. [BetterSpecs](http://www.betterspecs.org/), while informative, also appears to be outdated with the most recent substantial changes occuring about two years ago. \n\t\n\t6. [The RSpec Book](https://pragprog.com/book/achbd/the-rspec-book) is multiple versions and seven years behind at this time. \n\n\t7. There are minimal blog posts with information very spread out.\n\n\t8. [CodeSchool's RSpec Course](http://rspec.codeschool.com/levels/1) is.. meh. Their new one requires a subscription.\n\n\t9. There is an official up-to-date beta [Effective Testing with RSpec 3](https://pragprog.com/book/rspec3/effective-testing-with-rspec-3) book, however, it costs money and obviously, my goal is to achieve my learning without cost.\n\n6. This project took me way too long. Methods without tests include:\n\n\t1. gameboard.rb\n\n\t\t1. #win\n\n\t\t2. #draw\n\n\t\t3. #check_for_win\n\n\t\t4. #add_disc\n\n\t\t5. #turn\n\n\t\t6. #turns\n\n\t\t7. #play\n\n\t\t8. #instructions\n\n\t2. player.rb\n\n\t\t1. #take_turn\n\n\t3. game.rb\n\n\t\t1. play_game\n\t\t\n7. Looking back from further along, I realize that [TDD is dead](http://david.heinemeierhansson.com/2014/tdd-is-dead-long-live-testing.html). @benjaminapetersen and me had discussed testing previously and he had mentioned the idea of a 'spike/sprint.' You code first to get something working, then write a test if necessary, then refactor. This sounds much better than TDD. For this project, there was some cognitive dissonance when trying to get 100% test coverage, but I realize now that a dogmatic approach to testing can be a negative rather than a benefit. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonathanyiv%2Fconnect_four","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonathanyiv%2Fconnect_four","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonathanyiv%2Fconnect_four/lists"}