Class: XO::AI::AdvancedBeginner
- Defined in:
- lib/xo/ai/advanced_beginner.rb
Class Method Summary collapse
Methods inherited from Expert
Class Method Details
.get_moves(grid, player) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/xo/ai/advanced_beginner.rb', line 7 def self.get_moves(grid, player) smart_moves = super(grid, player) dumb_moves = all_moves - smart_moves # if there are no dumb moves then we have no choice but to make a smart move # otherwise, 75% of the time we'll make a smart move and the other 25% of the # time we'll make a dumb move dumb_moves.empty? ? smart_moves : (rand < 0.75 ? smart_moves : dumb_moves) end |