class TicTacToe::Game

Attributes

board[R]
computer_player[R]

Public Class Methods

new() click to toggle source
# File lib/tic_tac_toe/game.rb, line 7
def initialize
  @board = Board.new
  @rules = Rules.new(@board)
  @computer_player = ComputerPlayer.new
  @marks = ["X", "O"]
end

Public Instance Methods

get_mark_at(position) click to toggle source
# File lib/tic_tac_toe/game.rb, line 24
def get_mark_at(position)
  @board.get_mark_at(position)
end
in_progress?() click to toggle source
# File lib/tic_tac_toe/game.rb, line 14
def in_progress?
  return false if winner || tie
  return true
end
move(position) click to toggle source
# File lib/tic_tac_toe/game.rb, line 19
def move(position)
  @board.set_mark(current_mark, position)
  change_current_mark
end
tie() click to toggle source
# File lib/tic_tac_toe/game.rb, line 32
def tie
  @rules.tie
end
winner() click to toggle source
# File lib/tic_tac_toe/game.rb, line 28
def winner
  @rules.winner
end

Private Instance Methods

change_current_mark() click to toggle source
# File lib/tic_tac_toe/game.rb, line 42
def change_current_mark
  @marks.reverse!
end
current_mark() click to toggle source
# File lib/tic_tac_toe/game.rb, line 38
def current_mark
  @marks.first
end