This project is to demonstrate our knowledge of Object oriented programming 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.
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
The game starts by calling the bin/main.rb file where all other classes are called/required. The game is played on the CLI
Tic-Tac-Toe is a famous game where the aim is to have 3 consecutive tokens aligned vertically, horizontally or diagonally. For those who are new to the game these are the rules governing the game:
- In this game, not more than 2 players are allowed
- The players should enter their names
- The first player has to choose between the tokens X and O
- The players have to note that other tokens other than X and O are considered as invalid
- If the first player chooses "X" then the other player will automatically be assigned the token "O"
- The 3x3 board appears with numbers from 1-9 and players have to place their respective tokens inside the board
- The winner is the person who has aligned 3 consecutives token vertically, horizontally or diagonally
In this game project there are 3 main files
1- main.rb: This file is responsible for getting validated inputs from the user, outputting messages, and calling the game method.
2- player.rb: This file is responsible for storing player variables such as (name, sign).
3- game.rb: This file is contains the various game methods and calling the player method.
- Ruby
- VS code
To get this project up and running, you must already have ruby installed on your computer.
To get this project set up on your local machine, follow these simple steps:
- Open Terminal.
- Navigate to your desired location to download the contents of this repository.
- Copy and paste the following code into the Terminal: git clone https://github.com/enkog/Tic-Tac-Toe
- Hit enter.
- Once the repository has been cloned, navigate inside the repository and type: bin/main.rb This will run the game and you will be able to play it using the terminal.
- Have fun!
$ gem install rspec
To test the code, run rspec
from root of the folder using terminal.
Rspec is used for the test.
👤 Kamwa Emmanuelle Alix
- Github: @emmanuellekamwa
- Twitter: @AlixKamwa
- Linkedin: @emmanuelle-kamwa
👤 Oguadinma Nkiruka Ngozika
Contributions, issues and feature requests are welcome! Feel free to check the issues page.
Give a star if you like this project!
License
This project is MIT licensed.)