Skip to content

Instantly share code, notes, and snippets.

@dadon
Last active August 29, 2015 13:56
Show Gist options
  • Save dadon/9133945 to your computer and use it in GitHub Desktop.
Save dadon/9133945 to your computer and use it in GitHub Desktop.
class BehaviorSource(object):
def get_behavior(self, unit_data, state_data):
raise NotImplementedError
class LocalAIBehaviorSource(BehaviorSource):
pass
class GlobalAIBehaviorSource(BehaviorSource):
pass
class UserInputBehaviorSource(BehaviorSource):
pass
class BehaviorSourceManager(BehaviorSource):
def __init__(self, sources):
self.sources = sources
def get_behavior(self, unit_data, state_data):
current_behavior = None
for source in self.sources:
current_behavior = source.get_behavior(unit_data, state_data)
if current_behavior:
break
return current_behavior
hero_pve_manager = BehaviorSourceManager([UserInputSource(), LocalAISource()])
hero_pvp_manager = BehaviorSourceManager([GlobalAISource(), LocalAISource()])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment