DrInfy / sharpy-sc2

Python framework for rapid development of Starcraft 2 AI bots
MIT License
69 stars 28 forks source link

ref https://github.com/DrInfy/sharpy-sc2/issues/54 #57

Closed eladyaniv01 closed 4 years ago

eladyaniv01 commented 4 years ago

knowledge.py

 def configure_managers(self) -> Optional[List[ManagerBase]]:
        # override built in data manager
        self.data_manager = MyDataManager()
        self.knowledge.data_manager = self.data_manager

        # add our own custom manager
        self.larva_manager = LarvaManager()
        self.knowledge.larva_manager = self.larva_manager
        self.knowledge.set_managers(additional_managers=[self.larva_manager])

        return None  # Do not add overriding managers to additional managers
eladyaniv01 commented 4 years ago

not sure what is the purpose of the return None after the change is accepted i will update the relevant docs on the wiki

eladyaniv01 commented 4 years ago

Does not solve any of the requested changes in issue #54 .

can you please be a little more constructive?

However, there's no easy mechanism for accessing the added managers.

custom managers can be accessed via knowledge.manager_dict[type(manager)]

Using type as key has the benefit of some "compile-time" checks. It prevents adding multiple instances of the same manager (probably not needed).

this seems like one of the changes requested

It's important to preserve the order of sharpy's own managers, because the order affects how they are updated.

this was also done

DrInfy commented 4 years ago

With the current code knowledge.manager_dict[type(manager)] does not work. With the current code you need the instance of the manager to request the instance of manager. Which doesn't make any sense. The order of the managers is preserved with zero changes already.