Skip to content

Instantly share code, notes, and snippets.

@pumpkincouture
Created August 15, 2014 00:32
Show Gist options
  • Save pumpkincouture/015abbd3e6f2a55298fa to your computer and use it in GitHub Desktop.
Save pumpkincouture/015abbd3e6f2a55298fa to your computer and use it in GitHub Desktop.
class IntelComputerPlayer
attr_reader :comp_winning_combos
def initialize
@comp_winning_combos = [[1,2,3], [4,5,6], [7,8,9],
[1,4,7], [2,5,8], [3,6,9],
[1,5,9], [3,5,7]]
end
def comp_location(cells)
computer_spaces = []
cells.each do |k,v|
if cells[k] == "X"
computer_spaces << k
else
false
end
end
computer_spaces
end
def human_location(cells)
human_spaces = []
cells.each do |k,v|
if cells[k] == "O"
human_spaces << k
else
false
end
end
human_spaces
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment