0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
The connect_four.rb file contains classes for an object-oriented connect four game, designed to be played between two human players on the command line. Colored player symbols courtesy of the colorize gem. Play by creating an instance of Game and calling the play method on it.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.8.4
~> 2.8.0

Runtime

 Project Readme

connect_four¶ ↑

Play connect four in the command line!

This gem allows for two players to play Connect Four in the terminal.

Play by requiring ‘connect_four’, creating an instance of the Game class, and then calling the play method on that Game object.

Under the hood:

The board is a 6x7 array of Cell objects, which hold their state (open or occupied) and their searchpaths. Searchpaths are the game’s way of determining a winner. Each cell has a collection of valid searchpaths, routes the game will travel outward radially up to 3 spaces from the starting cell to look for adjacent moves by the given player. For example, the bottom right cell has N, NE, and E as its searchpaths, since going any direction other than those would take us off the board. After every player’s turn, the game will travel all the searchpaths of every cell on which that player has made a move. If all three cells on the path (plus the starting cell) are in that player’s move history, then that player is declared the winner and the game is over.

Contributing to connect_four¶ ↑

  • Check out the latest master to make sure the feature hasn’t been implemented or the bug hasn’t been fixed yet.

  • Check out the issue tracker to make sure someone already hasn’t requested it and/or contributed it.

  • Fork the project.

  • Start a feature/bugfix branch.

  • Commit and push until you are happy with your contribution.

  • Make sure to add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright © 2012 Price Hardman. See LICENSE.txt for further details.