You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you want to check if a COMMANDCENTER is in a list, you need to calculate the tag list instead of checking the list itself. I think this behaviour applies to all units (didn't check). But this adds calculus and lines for nothing.
Enhancement would be:
class XXXX(...): #I don't know the name of the class
def __eq__(self, other):
return self.tag == other.tag
def __ne__(self, other):
return self.tag != other.tag
...etc
If you store commandcenters in a parallel list you cannot execute this check: for cc in self.units(UnitTypeId.COMMANDCENTER): if cc in parallel_list: ...
Filtering is useless in this case
It will find False because the eq changes each step
This doesn't solve the issue, you still can't determine if a commandcenter is in a list/unit-group without having to filter the list/unit-group looking for each commandcenter.
I agree that it would make sense to determine equality by tag. I was creating custom Units objects and it was sometimes easier to compare than filter() or find_by_tag().
Activity
mjschuetze102 commentedon Jul 2, 2018
What are you trying to achieve? Does self.units(UnitTypeId.COMMANDCENTER).ready not work for what you are trying to accomplish? Or perhaps using the filter method: https://github.com/Dentosal/python-sc2/wiki/Units-and-actions#filters
hyyking commentedon Jul 2, 2018
If you store commandcenters in a parallel list you cannot execute this check:
for cc in self.units(UnitTypeId.COMMANDCENTER): if cc in parallel_list: ...Filtering is useless in this case
It will find False because the eq changes each step
mjschuetze102 commentedon Jul 2, 2018
Use unit groups instead of a list? https://github.com/Dentosal/python-sc2/wiki/Units-and-actions#unit-groups
Then use the by_tag method to call the command center
https://github.com/Dentosal/python-sc2/blob/master/sc2/units.py#L58
hyyking commentedon Jul 3, 2018
This doesn't solve the issue, you still can't determine if a commandcenter is in a list/unit-group without having to filter the list/unit-group looking for each commandcenter.
k4pran commentedon Jul 3, 2018
I agree that it would make sense to determine equality by tag. I was creating custom Units objects and it was sometimes easier to compare than filter() or find_by_tag().