Skip to content

In this project we implement a command-line version of the popular Tic-Tac-Toe game in Ruby.

Notifications You must be signed in to change notification settings

RamseyNjire/tic-tac-toe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tic-Tac-Toe

forthebadge

In this project, we built a Tic Tac Toe game. The main goal is to put into practice the main concepts of Object Oriented Programming. Particularly, classes, objects and access to their attributes.

Built With

  • Ruby
  • VsCode

Live Demo

Live Demo Link

How to Play

This game consists of 2 players.

The first player to enter their name, or Player One, is assigned 'X', and the second player, or Player Two, is assigned 'O'.

screenshot

A board, which consists of a 3x3 grid cell, is displayed.

screenshot

The game starts with the first player choosing any of the cells from 1 to 9. The board is updated with the player's symbol ('X' or 'O') at the cell they chose.

The next player then picks a cell number and the game continues in alternating fashion.

screenshot

The objective of the game is to fill in 3 cells in a row with your letter, either horizontally, vertically, or diagonally.

The game ends in one of 2 scenarios: One player succeeds at filling 3 cells in a row or all cells are filled and no player wins, that is a draw. The game will output the appropriate message in either case.

screenshot

Note that you can't enter anything other than a number from 1-9 when picking a cell. The game will throw an error and ask you to pick a valid number.

screenshot

Also, you can't pick a cell that has been previously filled with either an 'X' or an 'O'. The game will inform you that the cell is not empty.

screenshot

Getting Started

To get a local copy up and running follow these simple example steps.

  • Clone this repository into your local machine

  • Run the main file by navigating to whatever directory you cloned the repo into and typing the following in your command line:

    cd tic-tac-toe/bin

    ruby main

An interesting thing to note here is that, since the main file is an executable, you should be able to run it, even if you're not in the tic-tac-toe folder. All you have to do is type the command main on the command line and the game should run, even without using the ruby prefix. However, seeing as different environments can be unpredictable, if that doesn't work then the above steps are the surest to get the game running.

Validators

  • Rubocop via Github Actions

Authors

👤 Ramsey Njire

👤 Peris Ndanu

🤝 Contributing

Contributions, issues and feature requests are welcome!

Feel free to check the issues page.

Show your support

Give a ⭐️ if you like this project!

📝 License

This project is MIT licensed.

About

In this project we implement a command-line version of the popular Tic-Tac-Toe game in Ruby.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages