Skip to content

Command-line project emulating the classic Tic-Tac-Toe game. Built with Ruby.

License

Notifications You must be signed in to change notification settings

Milypm/Ruby_OOP_TicTacToe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OOP with Ruby: Tic-Tac-Toe game

In this project we created a game emulating the classic 'Tic Tac Toe'. It is made to run on the terminal/command line, and interacts with the user. The file (main) is executable, so it can run easily.

Built With

  • Ruby
  • Rubocop
  • Git

How to run it

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

  • If you're using latest version of git.
  • Clone this url Tic-Tac-Toe on your local host.
  • Unzip and open the folder that contains the main.rb file and run the command line in terminal: -Type: main.rb (if you are already on the 'bin' folder, if not type: bin/main.rb)
  • The program (game) should display now on the terminal

Live Demo Link

Game rules

  • Each player needs a unique name to identify them.
  • A player is assigned a unique symbol that is either 'X' or 'O'.
  • A player should choose a position on the board that is not yet taken.
  • Once a player makes a move, that move is displayed on the board in the position that they have chosen.
  • A player is deemed the winner as soon as they have 3 of their moves either registered in a row, column, diagonal or cross diagonal.
  • In the event that no player has won and the board is full, that game is registered as a Draw. ​

How to play the game

  • Enter your name and press enter, you will be assigned a symbol as soon as you enter your name, take note of your symbol.
  • Make a move by entering a number in the range [1, 2, 3, 4, 5, 6, 7, 8, 9] which corresponds to a position on the board you intend to move to.
  • Make sure the position you're choosing has a number not a symbol of the player.
  • After each move your symbol will be displayed on the board in the position you choose.
  • Keep making the moves until when one of you wins or a draw is reached if all moves have been exhausted and there is no winner.

Testing with RSpec

  • Verify that you have RSpec installed: go to the Terminal/Command line and type: 'rspec -v' or 'rspec --version'.
  • To install Rspec: go to the Terminal/Command line and type: 'gem install rspec', you can now verify the version installed with 'rspec -v' or 'rspec --version'.
  • Open the root directory for this repository ('Ruby_OOP_TicTacToe'):
    • For running RSpecs on both 'game.rb' and 'player.rb 'files, type: rspec

Authors

Galiwango Ananiya

Mily Puente

Show your support

Give a star if you like this project!

License

This project is MIT licensed.

About

Command-line project emulating the classic Tic-Tac-Toe game. Built with Ruby.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages