Converting Python bot to minimal Sharpy bot - DrInfy/sharpy-sc2 GitHub Wiki
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.