Created
May 21, 2016 17:18
-
-
Save angelxmoreno/dd779ecc060463242739f7c35eb91a63 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
By adding this gem to our project we will be able to use methods of the Tic_Tac_Toe class (these methods are listed below) | |
.new - makes a new Tic Tac Toe object | |
.initBoard(board) - makes a cell block from the dimensions of board object | |
.winningRows(board) - checks the board object to see if a row contains 3 of the same symbol | |
.winningCols(board) - checks the board object to see if a col contains 3 of the same symbol | |
.winningDiagonals(board) - checks the board object to see if a diagonal contains 3 of the same symbol | |
.displayBoard(board) - displays board object in the terminal | |
.fullBoard(board) - checks to see if the board object is full | |
.turnPlayed(board,player,player_choice) - checks to see if a valid move was played by checking the board object, player symbol and location that the player picked | |
Note: board is simply an 2-D array object | |
Here is an example of how we make a new Tic Tac Toe object and can call the initBoard method | |
game = Tic_Tac_Toe.new | |
board = Array.new(3) {Array.new(3)} | |
game.initBoard(board) | |
Student Practice: | |
In order to use a gem, we need to install it first. Tell the student to use the terminal to type: | |
gem install tic_tac_toe_cn |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment