Created
August 15, 2014 00:32
-
-
Save pumpkincouture/015abbd3e6f2a55298fa to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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