We built 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.
Tic-tac-toe is a 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 diagonal, horizontal, or vertical row is the winner.
- Ruby
- Rspec
- Copy this link
- Open your terminal or command line
- Run "git clone Paste this link"
- Boot up your terminal and punch in "gem install rspec" to install RSpec
- You can verify your version of RSpec with "rspec --version"
- cd into project directory "Tic-Tac-Toe" and type "rspec --init" to initialize RSpec within the project
- This will generate two files, ".rspec" and "spec/spec_helper.rb"
- You can create the ruby test file inside the sprc directory (eg: logic_spec.rb, player_spec.rb)
- You can simply run "rspec" in the terminal by cd into the directory in order torun the tests
- You can also run "rspec file-path" for the particular file you want to test from the directory
- You can run "rubocop" inorder to check the linter errors
- This game can be played between any two people.
- Run "ruby main.rb" in your terminal
- Initially, it will be asked to enter your names (for player 1 and player 2)
- You can enter minimum two characters of your name to move forward
- The first player will play with '❌' and the other with '⭕️'
- It will be player turnwise, Player 1 goes first, then Player 2, then again Player 1, likewise until you reach the following condition
- For winning this game, one has to create a row/column/diagonal of three '❌'s or '⭕️'s first
- If no one will be able to make so, it will be a tie and will ask for continuing another match or quit the game
Tip: If you're going first, then the best move you can make is to move into the center. This will maximize your chances of winning
👤 Bhagyashree Patra
- GitHub: @Vagyasri
- Twitter: @Vagyasri
- LinkedIn: Bhagyashree Patra
Contributions, issues, and feature requests are welcome!
Start by:
- Forking the project
- Cloning the project to your local machine
- Run git checkout -b your-branch-name
- Make your contributions
- Push your branch up to your forked repository
- Open a Pull Request with a detailed description to the development branch of the original project for a review
Feel free to check the issues page, contribute to the Project by creating an issue.
Give a ⭐️ if you like this project!