Class: TresRaya::DumbPlayer
- Inherits:
-
Player
- Object
- Player
- TresRaya::DumbPlayer
show all
- Defined in:
- lib/tres_raya/dumb_player.rb
Instance Attribute Summary
Attributes inherited from Player
#mark
Instance Method Summary
collapse
Methods inherited from Player
#initialize
Instance Method Details
#finish(final_board) ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/tres_raya/dumb_player.rb', line 8
def finish( final_board )
if final_board.won? == @mark
win = 1
elsif final_board.won? == " "
win = 0
else
win = -1
end
win
end
|
#move(board) ⇒ Object
3
4
5
6
|
# File 'lib/tres_raya/dumb_player.rb', line 3
def move( board )
moves = board.moves
moves[rand(moves.size)]
end
|