-
Notifications
You must be signed in to change notification settings - Fork 29
Converting Python bot to minimal Sharpy bot
DrInfy edited this page Dec 4, 2020
·
1 revision
You should use SkeletonBot
when converting a normal python bot to Sharpy bot.
Let's say we have a class called MyBot
class MyBot(SkeletonBot):
def __init__(self):
# My init code here
async def on_start(self):
# My start code here
async def on_step(self, iteration):
# My logic code here
async def on_unit_destroyed(self, unit_tag: int):
# My code here
async def on_end(self, game_result: Result):
# My code here
Convert your bot into something like this:
from typing import Optional, List
from sharpy.knowledges import SkeletonBot
class MyBot(SkeletonBot):
def __init__(self):
self.realtime_split = True # No worker split on minerals
self.realtime_worker = True # First worker
super().__init__("bot name")
# My init code here
def configure_managers(self) -> Optional[List["ManagerBase"]]:
return []
async def execute(self):
iteration = self.knowledge.iteration
# your old code from on_step method
async def on_start(self):
await super().on_start()
# My start code here
async def on_unit_destroyed(self, unit_tag: int):
await super().on_unit_destroyed(unit_tag)
# My code here
async def on_end(self, game_result: Result):
await super().on_end(game_result)
# My code here
Note the "on_step" change to "execute".
To take advantage of the sharpy match runner and the automated ladder zip / publish function, you'll need to register your bot definitions.
- 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