Class: TicTacToe::Computer
- Defined in:
- lib/tic_tac_toe_mchliakh/players/computer.rb
Instance Method Summary collapse
Methods inherited from Player
Constructor Details
This class inherits a constructor from TicTacToe::Player
Instance Method Details
#next_move ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/tic_tac_toe_mchliakh/players/computer.rb', line 3 def next_move line = any_winning_line || any_losing_line if line line.squares.empty.sample else fork_squares.sample || fork_safe_square || @board.squares.empty.max_by(&:line_count) end end |