The famous game: Tic-Tac-Toe
Tic-Tac-Toe is one of the most famous games in the world. We have implemented it using only Ruby. You can choose your names and play against each other. We tried to make it easy to follow the table by colorizing the numbers, "x" and "o". Don't let him/her beat you 😉
- Ruby
- Object Oriented Programming
You need 2 players to play the game!
To get a local copy:
- Run this command in your teminal
git clone https://github.com/edxco/tic-tac-toe/
. - Then run this one
cd tic-tac-toe
- Then to start playing run this
bin/main.rb
- Ruby installed on your machine
Clone or download the source code, and run it in your teminal.
Start the game by running this code in your teminal bin/main.rb
.
You start the game by entering your names, then the computer will randomly choose one of you to choose his sign. You can only choose "x" or "o". After choosing your signs, the first player will choose from 1-9 to put his sign in that index as shown in below image:
Once the first player choose an index, that index will be changed to his sign as shown below:
Then it's other player turn. The second player now should choose his sign in order not to allow the first player to win.
- Diagonally: When you have your signs aligned diagonally
- Column: When you have your signs in just one column
- Row: When you have your signs in a single row.
You can use Rubocop to test the code.
In case Rubocop is not installed on your machine, enter this command to install it gem install rubocop
. You may be required to run the terminal as an administrator.
Once Rubocop is installed, you simply run rubocop
in the terminal to test the code.
We have already created multiple files
player_spec.rb
andtable_spec.rb
, if you want to create another one with the end[your file name]
_spec.rb
- Open
player_spec.rb
ortable_spec.rb
file - Open a terminal window and type
rspec
- If all test were passed you will see:
Else you'll see a red message, then check errors and fix them
👤 Martin Najjar
- GitHub: @githubhandle
- Twitter: @twitterhandle
- LinkedIn: LinkedIn
👤 Eduardo Baeza
- GitHub: @githubhandle
- Twitter: @twitterhandle
- LinkedIn: LinkedIn
👤 Khristian Rojas
- Github: @githubhandle
- Twitter: @twitterhandle
- Linkedin: linkedin
Contributions, issues, and feature requests are welcome!
Feel free to check the issues page.
Give a ⭐️ if you like this project!
- Microverse
- The Odin Project
- Tic-Tac-Toe logic
This project is MIT licensed.