Skip to content

Instantly share code, notes, and snippets.

@mjansen401
Created April 4, 2011 12:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjansen401/901578 to your computer and use it in GitHub Desktop.
Save mjansen401/901578 to your computer and use it in GitHub Desktop.
AI Abstract Factory
class UnbeatableFactory
def self.create
Minimax.new
end
end
class EasyFactory
def self.create
Random.new
end
end
class AIFactory
def create_ai(ai_type)
if ai_type == :unbeatable
return UnbeatableFactory.create
elsif ai_type == :easy
return EasyFactory.create
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment