Skip to content

Instantly share code, notes, and snippets.

@itzsaga
Created March 20, 2017 03:39
Show Gist options
  • Save itzsaga/46f4129f8acf3a042a6b630521595da3 to your computer and use it in GitHub Desktop.
Save itzsaga/46f4129f8acf3a042a6b630521595da3 to your computer and use it in GitHub Desktop.
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