Ruby Project: Tic Tac Toe (Object-Oriented Programming)

Click here to view this project on Github.

This is an object-oriented programming implementation of Tic Tac Toe written in Ruby. The game runs in the command line, but the design is intentionally OOP: the Board is responsible for board state and win detection, Square encapsulates marker behavior, Player tracks player identity and score, and TTTGame coordinates the overall game flow (turn-taking, input, scoring, and replay). The computer opponent includes basic strategy (win if possible, block if needed, take center, otherwise choose randomly), and the match format is first to 5 wins.

Skills demonstrated:

  •     Ruby
  •     Object-oriented programming (classes, encapsulation, collaboration)
  •     Program design (separation of responsibilities across objects)
  •     State management (board state, turns, scoring, resets)
  •     Control flow (game loops, turn loops, replay logic)
  •     Data structures (arrays, hashes, constants for winning lines)
  •     Input validation and user prompts
  •     Game logic (win detection, “at risk” squares, simple AI decision-making)

Leave a Reply

Your email address will not be published. Required fields are marked *