Class: TakaTicTacToe::Computer
- Inherits:
-
Object
- Object
- TakaTicTacToe::Computer
- Defined in:
- lib/taka_tic_tac_toe/computer.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#difficulty ⇒ Object
readonly
Returns the value of attribute difficulty.
-
#mark ⇒ Object
readonly
Returns the value of attribute mark.
-
#opponent_mark ⇒ Object
readonly
Returns the value of attribute opponent_mark.
Instance Method Summary collapse
-
#initialize(mark, opponent_mark) ⇒ Computer
constructor
A new instance of Computer.
- #make_move(board) ⇒ Object
- #set_difficulty(difficulty) ⇒ Object
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
#difficulty ⇒ Object (readonly)
Returns the value of attribute difficulty.
3 4 5 |
# File 'lib/taka_tic_tac_toe/computer.rb', line 3 def difficulty @difficulty end |
#mark ⇒ Object (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_mark ⇒ Object (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 |