Class: Game

Inherits:
Object
  • Object
show all
Defined in:
lib/game.rb

Instance Method Summary collapse

Constructor Details

#initialize(board, players) ⇒ Game

Returns a new instance of Game.



3
4
5
6
# File 'lib/game.rb', line 3

def initialize(board, players)
  @board = board
  @players = players
end

Instance Method Details

#playObject



8
9
10
11
12
13
14
# File 'lib/game.rb', line 8

def play
  while game_in_progress?
    current_player = players[player_symbol]
    @board = board.make_move(current_player.choose_move(board), player_symbol)
  end
  board
end

#play_specific(move) ⇒ Object



16
17
18
19
# File 'lib/game.rb', line 16

def play_specific(move)
  @board = board.make_move(move, player_symbol)
  play
end