This is Tic-Tac-Toe using negamax for AI. Help me make it better!
Some sore points are:
def get_mark
good_mark = false
until good_mark
mark = gets.chomp
if mark =~ /x/i
chose_x
good_mark = true
elsif mark =~ /o/i
chose_y
good_mark = true
else
puts <<-EOS.gsub(/^ */, '')
What is this strange mark? please choose 'X' or 'O'!
EOS
end
end
end
and
def game_won?
@solutions.clear
make_solutions
won = false
@solutions.each do |solution|
if solution[0] != ' ' &&
solution[0] == solution[1] && solution[1] == solution[2]
won = true
end
end
return won
end
The rest of this is here.