Open Source Your Knowledge, Become a Contributor
Technology knowledge has to be shared and made accessible for free. Join the movement.
Welcome!
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 wins the game.
Hands-on Code
Playing...
1
2
3
4
5
6
7
require_relative 'tic_tac_toe.rb'
# board = ["X", "X", "X", "X", "O", "O", "X", "O", "O"]
# game = TicTacToe.new(board)
game = TicTacToe.new
game.display_board
game.play
Enter to Rename, Shift+Enter to Preview
1
class TicTacToe
Enter to Rename, Shift+Enter to Preview
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content