Class: TTT::AIMedium

Inherits:
AI show all
Defined in:
lib/ttt/ai_medium.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

#move(options) ⇒ Object



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

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

#set_max_ply(moves) ⇒ Object



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

def set_max_ply(moves)
  if moves > 15
   return 3
  elsif moves > 5
   return 5
  else
   return 7
  end
end