Class: TTT::AIHard

Inherits:
AI show all
Defined in:
lib/ttt/ai_hard.rb

Instance Attribute Summary

Attributes inherited from AI

#board, #max_ply

Attributes inherited from Player

#side

Instance Method Summary collapse

Methods inherited from AI

#available_moves, #no_gui?, #opposite_side, #prompt, #undo_move

Methods included from Minimax

#alpha_beta_swapped?, #base_case_satisfied?, #eval_score, #gen_score_game_tree, #mark_curr_player_side, #minimax, #winning_score

Methods inherited from Player

#==, #initialize

Constructor Details

This class inherits a constructor from TTT::Player

Instance Method Details

#max_ply_for(moves) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/ttt/ai_hard.rb', line 11

def max_ply_for(moves)
  if moves > 16
    return 7
  elsif moves > 10
    return 9
  else
    return 11
  end
end

#move(options) ⇒ Object



5
6
7
8
9
# File 'lib/ttt/ai_hard.rb', line 5

def move(options)
  super
  self.max_ply = max_ply_for(available_moves.length)
  minimax
end