Connect Four is a game I enjoyed playing with my friends, now it is available to play right in your terminal.
# Clone the repository
git clone https://github.com/AncientNimbus/rb-connect-four.git
cd rb-connect-four
# Install dependencies
bundle install
# Run the game
bundle exec ruby main.rb
# Display help
--help
# Quit the program
--ttfn
# Launch Connect four
--play connect4
- Select a game mode
- Mode [1]: Player vs Player
- Mode [2]: Player vs Computer (Coming soon!)
- The game will randomly decide who goes first
- Player will each take turn to drop a coloured disc into a column
- To drop the coloured disc, enter a column number between 1 to 7
- Try to connect four of your discs in a row up and down (vertical), side to side (horizontal), or diagonally
- The first player to get four of their coloured discs in a row wins! If the whole grid fills up and no one has four in a row, the game is a tie.
Core Objectives
- Written with Ruby
- TDD approach
- OOP software architecture
Additional Objectives
- UX design for terminal game
- Localisation ready
Implementation highlights
- Robust input handling (Butterfingers-proof)
- Mathematical Grid system
- Precomputed Lookup Table
- Win condition detection via
Set
- Localisation ready via
YAML
configuration file - Colourful game interface with terminal interface
Performance Optimisation
- All possible winning combinations are calculated once at startup
- Validation order: Check recent moves first for faster win detection
- Single formula that handles 6 movement directions
Error handling
- User input is validate against Regex pattern
- Warning is displayed when user attampted to add disc to a full row
- RSpec
- Rubocop
- Colorize
- Yard