Class: TakaTicTacToe::Computer

Inherits:
Object
  • Object
show all
Defined in:
lib/taka_tic_tac_toe/computer.rb

Direct Known Subclasses

EasyAi, ImpossibleAi, MediumAi

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mark, opponent_mark) ⇒ Computer

Returns a new instance of Computer.



5
6
7
8
# File 'lib/taka_tic_tac_toe/computer.rb', line 5

def initialize(mark, opponent_mark)
  @mark = mark
  @opponent_mark = opponent_mark
end

Instance Attribute Details

#difficultyObject (readonly)

Returns the value of attribute difficulty.



3
4
5
# File 'lib/taka_tic_tac_toe/computer.rb', line 3

def difficulty
  @difficulty
end

#markObject (readonly)

Returns the value of attribute mark.



3
4
5
# File 'lib/taka_tic_tac_toe/computer.rb', line 3

def mark
  @mark
end

#opponent_markObject (readonly)

Returns the value of attribute opponent_mark.



3
4
5
# File 'lib/taka_tic_tac_toe/computer.rb', line 3

def opponent_mark
  @opponent_mark
end

Instance Method Details

#make_move(board) ⇒ Object



14
15
16
# File 'lib/taka_tic_tac_toe/computer.rb', line 14

def make_move(board)
  @difficulty.make_move(board)
end

#set_difficulty(difficulty) ⇒ Object



10
11
12
# File 'lib/taka_tic_tac_toe/computer.rb', line 10

def set_difficulty(difficulty)
  @difficulty = difficulty.new(@mark, @opponent_mark)
end