Class: RockPaperScissors::Computer

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

Instance Attribute Summary

Attributes inherited from Player

#name

Instance Method Summary collapse

Constructor Details

#initialize(board, player_number) ⇒ Computer

Returns a new instance of Computer.



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

def initialize(board, player_number)
  super(board, player_number)
  @name = "Skynet"
end

Instance Method Details

#select_moveObject



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

def select_move
  move = @board.plays.keys.sample.to_s
  @board.place_move(@player_number, move)
end