class Tictactoe::Ai::RandomChooser
Attributes
random[RW]
Public Class Methods
new(random)
click to toggle source
# File lib/tictactoe/ai/random_chooser.rb, line 4 def initialize(random) @random = random end
Public Instance Methods
choose_one(list)
click to toggle source
# File lib/tictactoe/ai/random_chooser.rb, line 8 def choose_one(list) index = bounded_random list.size list[index] end
Private Instance Methods
bounded_random(outer_bound)
click to toggle source
# File lib/tictactoe/ai/random_chooser.rb, line 16 def bounded_random(outer_bound) (random.rand * outer_bound).to_i end