Class: TTT::AI
Instance Attribute Summary collapse
Attributes inherited from Player
#side
Instance Method Summary
collapse
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 Attribute Details
#board ⇒ Object
Returns the value of attribute board.
7
8
9
|
# File 'lib/ttt/ai.rb', line 7
def board
@board
end
|
#max_ply ⇒ Object
Returns the value of attribute max_ply.
7
8
9
|
# File 'lib/ttt/ai.rb', line 7
def max_ply
@max_ply
end
|
Instance Method Details
#available_moves ⇒ Object
17
18
19
|
# File 'lib/ttt/ai.rb', line 17
def available_moves
board[].each.with_index.map { |element, index| index if element == " " }.compact
end
|
#move(options) ⇒ Object
9
10
11
|
# File 'lib/ttt/ai.rb', line 9
def move(options)
self.board = (options[:board].dup)
end
|
#no_gui? ⇒ Boolean
25
26
27
|
# File 'lib/ttt/ai.rb', line 25
def no_gui?
true
end
|
#opposite_side(side) ⇒ Object
13
14
15
|
# File 'lib/ttt/ai.rb', line 13
def opposite_side(side)
side == "x" ? "o" : "x"
end
|
#prompt ⇒ Object
29
30
31
|
# File 'lib/ttt/ai.rb', line 29
def prompt
"Computer thinking."
end
|
#undo_move(index) ⇒ Object
21
22
23
|
# File 'lib/ttt/ai.rb', line 21
def undo_move(index)
board[][index] = " "
end
|