-
Notifications
You must be signed in to change notification settings - Fork 30
Extending Managers
DrInfy edited this page Apr 17, 2020
·
18 revisions
In order to customize managers, override configure_managers
method in KnowledgeBot
.
Following example makes simple implementation for build selection in data manager.
class MyDataManager(DataManager):
""" Simple replacement to data manager"""
def select_build(self, available_builds: List[str]) -> str:
""" Selects last build if it won and another if it didn't win. """
if len(available_builds) == 1:
return available_builds[0]
assert len(available_builds) > 1
last = self.last_result
if last is not None and last.build_used in available_builds:
if last.result > 0:
return last
available_builds.remove(last)
return available_builds[randint(0, len(available_builds) - 1)]
class MyBot(KnowledgeBot):
def configure_managers(self) -> Optional[List[ManagerBase]]:
self.knowledge.data_manager = MyDataManager() # Replace default data manager with our extended one
return None
async def create_plan(self) -> BuildOrder:
builds = ["timing", "macro", "rush"] # Our build selection
selected_build = self.knowledge.data_manager.select_build(builds)
self.knowledge.data_manager.set_build(selected_build)
return self.create_build(selected_build)
def create_build(self, selected_build: str) -> BuildOrder:
# Make your own implementation of the available builds
if selected_build == "timing":
return # ...
if selected_build == "macro":
return # ...
if selected_build == "rush":
return # ...
- Plans and Build Order
- Settings, debug and logging
- Structure and Life Cycle
- Unit Roles
- Unit Cache
- Running Games
- Converting Sharpy bot from before 2.0 version
- Converting Sharpy KnowledgeBot to SkeletonBot
- Converting Python bot to minimal Sharpy bot
- OLD: Extending Your Existing Bot With Sharpy
- Packaging For Ladders
- Extending Sharpy
- Advanced Build Order tricks
- Machine Learning With Sharpy