Skip to content

Instantly share code, notes, and snippets.

@pumpkincouture
Created August 15, 2014 00:39
Show Gist options
  • Save pumpkincouture/facef8790b3fd33e660c to your computer and use it in GitHub Desktop.
Save pumpkincouture/facef8790b3fd33e660c to your computer and use it in GitHub Desktop.
def smart_move(cells)
comp_spaces = comp_location(cells)
wins_left = delete_from_array(cells)
comp_spaces.map!(&:to_i)
options = []
if comp_spaces.empty?
return [5]
else
@comp_winning_combos.each do |sub_array|
intersect = sub_array & comp_spaces
if intersect.any?
difference = sub_array - comp_spaces
options << difference
end
end
end
options.uniq!
options
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment