Class: TicTacToe::AI

Inherits:
Object
  • Object
show all
Defined in:
lib/ttt/ai.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mark, difficulty = :unbeatable_ai) ⇒ AI

Returns a new instance of AI.



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

def initialize(mark, difficulty = :unbeatable_ai)
  @mark = mark
  @difficulty = difficulty
end

Instance Attribute Details

#difficultyObject

Returns the value of attribute difficulty.



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

def difficulty
  @difficulty
end

#markObject (readonly)

Returns the value of attribute mark.



3
4
5
# File 'lib/ttt/ai.rb', line 3

def mark
  @mark
end

Instance Method Details

#make_move(board) ⇒ Object



11
12
13
14
15
16
# File 'lib/ttt/ai.rb', line 11

def make_move(board)
  move = { :difficulty => @difficulty,
           :board => board,
           :mark => @mark }
  AIRules::Factory.get(move)
end