Class: AI

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

Direct Known Subclasses

HardAI, MediumAI, RandomAI

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(game, computer) ⇒ AI

Returns a new instance of AI.



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

def initialize(game, computer)
  @game = game
  @board = game.board
  @computer = computer
  @enemy = @game.first_player
  @best_move = nil
end

Instance Attribute Details

#best_moveObject

Returns the value of attribute best_move.



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

def best_move
  @best_move
end

Class Method Details

.create(game, type, computer) ⇒ Object



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

def self.create(game, type, computer)
  type.new(game, computer)
end

Instance Method Details

#move_generateObject

Метод для генерации хода AI



19
# File 'lib/ttt-cli/ai.rb', line 19

def move_generate; end