Class: Tictactoe::Ai::RandomChooser
- Inherits:
-
Object
- Object
- Tictactoe::Ai::RandomChooser
- Defined in:
- lib/tictactoe/ai/random_chooser.rb
Instance Method Summary collapse
- #choose_one(list) ⇒ Object
-
#initialize(random) ⇒ RandomChooser
constructor
A new instance of RandomChooser.
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 |