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.