Created
March 20, 2017 03:39
-
-
Save itzsaga/46f4129f8acf3a042a6b630521595da3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Players | |
class Computer < Player | |
def move(board) | |
possible_moves = ["1", "2", "3", "4", "5", "6", "7", "8", "9"] | |
valid_moves = [] | |
possible_moves.each do |move| | |
valid_moves << move if board.cells[move.to_i-1] = " " | |
end | |
valid_moves.sample | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment