Skip to content

Instantly share code, notes, and snippets.

@mikeebert
Created May 18, 2012 15:36
Show Gist options
  • Save mikeebert/2725900 to your computer and use it in GitHub Desktop.
Save mikeebert/2725900 to your computer and use it in GitHub Desktop.
Minimax Players
class MinimaxPlayer
attr_accessor :symbol, :starting_score
def initialize(symbol, score)
@symbol = symbol
@starting_score = score
end
end
class MinPlayer < MinimaxPlayer
def compare(best_score,new_score)
new_score < best_score ? new_score : best_score
end
end
class MaxPlayer < MinimaxPlayer
def compare(best_score, new_score)
new_score > best_score ? new_score : best_score
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment