Vagyasri / Ruby-template

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tic-Tac-Toe

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.

Built With

  • Ruby
  • Rspec

Getting Started

To get a local copy run the following steps:

How to set up tests

  • 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)

How to run tests

  • 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

How to play "Tic-Tac-Toe"

  • 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

🎊 🎉 Have fun 🎊 🎉

Author

👤 Bhagyashree Patra

🤝 Contributing

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.

Show your support

Give a ⭐️ if you like this project!

About