Class: Tictactoe::Ai::RandomChooser

Inherits:
Object
  • Object
show all
Defined in:
lib/tictactoe/ai/random_chooser.rb

Instance Method Summary collapse

Constructor Details

#initialize(random) ⇒ RandomChooser

Returns a new instance of RandomChooser.



4
5
6
# File 'lib/tictactoe/ai/random_chooser.rb', line 4

def initialize(random)
  @random = random
end

Instance Method Details

#choose_one(list) ⇒ Object



8
9
10
11
# File 'lib/tictactoe/ai/random_chooser.rb', line 8

def choose_one(list)
  index = bounded_random list.size
  list[index]
end