Skip to content

This is project is to demonstrate our knowledge of Object-Oriented Programming Language in Ruby, building a tic-tac-toe game on the command line where two human players can play against each other and the board is displayed in between turns.

License

Notifications You must be signed in to change notification settings

descholar-ceo/tic-tac-toe

 
 

Repository files navigation

Implementing Tic Tac Toe Game with Ruby

View Code Github Issues GitHub Pull Requests

About   |    User Interface   |    Input   |    Output   |    Class Definitions   |    Built With   |    Live Demo   |    Getting Started   |    Authors

This project is to demonstrate our knowledge of Object Oriented Programming Language in Ruby, building a tic-tac-toe game on the command line where two human players can play against each other and the board is displayed in between turns.

screenshot

About the Game - Tic-Tac-Toe

According to Wikipedia Tic-tac-toe (American English), noughts and crosses (British English), or Xs and Os is a paper-and-pencil game for two players, X and O, who take turns marking the spaces in a 3×3 grid. The player who succeeds in placing three of their marks in a horizontal, vertical, or diagonal row is the winner...readmore

screenshot

User Interface

The game starts by calling the bin/main.rb file where all other classes are called/required. The game is played on the CLI

Instructions

Input

  • At the beginning of the game, the two players are requested to enter their names, one after the other.
  • The first person to enter his/her name automatically becomes player 1 and is requested to enter values between [1 - 9] to mark a piece on the board.
  • Player 1 is automatically assigned to piece "X" and player 2 piece "O"

Output

  • The board class is instantiated at the beginning of the game with unmarked spots 1 to 9 on a 3x3 grid.
  • The game board is re-rendered on the screen to show player's current placement of piece. Example if player 1 takes position 5, is replaced with "X" and becomes unvailable till the end of the game.
  • This repeats until win or draw conditions are met
  • Players instructions are error messages are displayed at each intervals to guide the players

Class Definitions

Game Class:

The game class initializes the board class and the player class. It handles the check winner and draw methods as well as switch player method.

Player Class:

Will interact with Board class to select where to place pieces Pieces placed will be represented by X or O

Board Class:

Will display the game board as well as locations of marked spots Take input from players to determine where to show marked spots

Built With

  • Ruby

🔴 Live Demo

Run on Repl.it

Getting Started

To get a local copy of the repository please run the following commands on your terminal:

$ cd <folder>
$ git clone https://github.com/acushlakoncept/tic-tac-toe.git

To run the code:

$ bin/main.rb

Testing

Install Rspec
$ gem install rspec

To test the code, run rspec from root of the folder using terminal.

Rspec is used for the test.

Authors

👤 Uduak Essien

👤 Elijah Ayandokun

🤝 Contributing

Contributions, issues and feature requests are welcome!

Show your support

Give a ⭐️ if you like this project!

Acknowledgments

  • Project originally taken from The Odin Project
  • Project inspired by Microverse

About

This is project is to demonstrate our knowledge of Object-Oriented Programming Language in Ruby, building a tic-tac-toe game on the command line where two human players can play against each other and the board is displayed in between turns.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%