Skip to content

Latest commit

 

History

History
74 lines (49 loc) · 2.84 KB

README.md

File metadata and controls

74 lines (49 loc) · 2.84 KB

TDD Connect Four

Images

Introduction

In this project, i built the classic game Connect Four using Ruby and the Test-Driven Development (TDD) approach. Connect Four is a two-player game where players take turns dropping pieces into a grid, aiming to get four of their pieces in a row, column, or diagonal.

Project Overview

The main objective of this project is to implement the Connect Four game in a command-line interface while applying TDD principles. i wrote tests first, then implement the code to pass those tests, ensuring my game is robust and well-tested.

Features

  • Two-Player Gameplay: Players alternate turns to drop pieces into the grid.
  • Win Condition: The game checks for four consecutive pieces in a row, column, or diagonal to declare a winner.
  • Command-Line Interface: The game runs in the terminal, allowing players to input their moves.
  • Unicode Symbols: Optionally, use Unicode symbols to represent game pieces for a more visually appealing experience.

Assignment Steps

  1. Set Up the Project:

    • Create a new Ruby project.
    • Set up RSpec for testing.
  2. Implement TDD:

    • Identify the core functionalities of the game (e.g., dropping pieces, checking for a win, switching turns).
    • Write failing tests for each functionality.
    • Implement the code to pass the tests.
    • Refactor the code to improve readability and performance.
  3. Game Logic:

    • Implement the logic for dropping pieces into the grid.
    • Check for a win condition in rows, columns, and diagonals.
    • Ensure the game handles edge cases, such as full columns.
  4. Command-Line Interface:

    • Create a user-friendly interface for players to input their moves.
    • Display the game board after each move.
    • Announce the winner or declare a draw if the board is full.

How to Run the Project

  1. Clone the Repository:
    git clone https://github.com/your-username/connect-four.git
    cd connect-four
    
  2. Install Dependancies:
    bundle install
    
  3. Run tests:
    rspec
    
  4. Play the game:
     ruby lib/connect_four.rb
    

Learning Objectives

  • Test-Driven Development: Gain proficiency in TDD by writing tests before implementing functionality.
  • RSpec: Learn to write and run tests using the RSpec testing framework.
  • Ruby Programming: Enhance your Ruby programming skills by building a complete game.
  • Problem-Solving: Develop problem-solving skills by breaking down the game logic into manageable parts and writing tests for each part.

Conclusion

This project is an excellent opportunity to practice TDD while building a fun and interactive game. By following the TDD approach, i ensure your code is well-tested and maintainable. I enjoyed the process of building Connect Four and showcasing my skills in Ruby and TDD!