This project is part of the Microverse Ruby Section!
Report Bug
·
Request Feature
Tic-tac-toe (American English), noughts and crosses (British English), or Xs and Os is a paper-and-pencil 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 horizontal, vertical, or diagonal row is the winner.
Game Rules:
- Two player game
- First player plays with the 'O' symbol
- Second player plays with the 'X' symbol
- Players take turns choosing a cell of the board to mark their symbol.
- A player can only choose an empty cell.
- The first player to complete a succession of 3 of their assigned symbol (O's or X's) in a row, column or diagonal wins!
- If all of the cells are filled with a symbol and no player matched 3 symbols, the game ends in a tie.
In here you will find a Tic-Tac-Toe game.
The game has a basic interface that runs in the terminal.
The goals of this project are:
- Practice with OOP (Object Oriented Programming) using Ruby as the language of choice.
- Learn how to structure a Ruby project.
- Correct use of logic and interface files to keep code maintainable.
- Practice of Git Flow and Github Flow creating branches for the different features.
This is also part of the Odin project curriculum https://www.theodinproject.com/courses/ruby-programming/lessons/oop
You need to have Ruby installed in your computer to run this file: https://www.theodinproject.com/courses/web-development-101/lessons/installing-ruby
You can download the repo or clone (paste on the terminal) git clone [email protected]:majovainilla/tic-tac-toe-game.git
You will need to execute the main.rb file located inside the bin folder. If you are using Window, follow next step. If you are using Linux or Mac, you can follow the instructions to make the file executable.
Open the terminal and navigate to the folder containing the tic-tac-toe game. Once you are inside, your terminal should look like this: User/<folder>/tic-tac-toe/
. You can type bin/main.rb
to run the game.
Enjoy!! And follow the next instructions to play.
Once you run the game, follow the prompts and instructions inside the terminal.
- The game is played inside the terminal.
- You play by typing the commands in the terminal.
- You will be prompted to type the Player 1 name and Player 2 name (press enter after each name)
- The first player will play with the 'O' symbol, and the second player with the 'X' symbol
- The game will prompt which player turn's it is.
- The board has three rows and three columns. a. Rows are named a,b,c from top to bottom. b. Columns are named 1,2,3 from left to right.
- The player in turn should type a valid cell name and enter it to mark the board.
- A valid cell name is comprised by a row (letter) and column (name): 'a1', 'b3'.
- After each turn, you will see the updated board with the selections of the players. Example of a game board after the first player types in "a1" in their turn:
a [ ][O][ ] b [ ][ ][ ] c [ ][ ][ ]
- A player can only mark an empty cell. If they choose an already marked cell they will be prompted again.
- The first player to match a succession of 3 of their assigned symbol (O's or X's) in a row, column or diagonal wins!
- If all of the cells are filled with a symbol and no player matched 3 symbols, the game ends in a tie.
- If you want to quit the game you can type "quit" instead of chosing a cell.
- After each game, you can choose to restart a new one. Type 'yes' or 'no' after the restart prompts. We will keep scores so play nice!!
This project was built using these technologies.
- Ruby
- VsCode
- Rubocop and Stickler for linting
This project contains tests made with RSpec, testing the critical methods inside the game_logic file.
The tests are contained within the spec folder in the game_logic_spec.rb file
Before running the tests make sure to install RSpec
You can run the tests by typing rspec
in the terminal, inside the root directory.
María José Reyes - @majovainilla - [email protected]
Sarah Uryelah Silva - @uryelah - @uryelah - [email protected]
Project Link: [https://github.com/majovainilla/tic-tac-toe-game)