Class: TTT::AIEasy

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



4
5
6
7
# File 'lib/ttt/ai_easy.rb', line 4

def move(options)
  super
  random_move
end

#random_moveObject



9
10
11
12
13
14
15
# File 'lib/ttt/ai_easy.rb', line 9

def random_move
  move = nil
  available_moves.each do |square|
    move ||= square if Time.new.usec % 3 == 0
  end
  return(move ? move : available_moves.last)
end