Skip to content

__eq__ not logical #69

Closed
Closed

Description

@hyyking

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

Activity

  1. mjschuetze102 commented on Jul 2, 2018

    @mjschuetze102
    Contributor

    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

  2. hyyking commented on Jul 2, 2018

    @hyyking
    Author

    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

  3. mjschuetze102 commented on Jul 2, 2018

    @mjschuetze102
    Contributor
  4. hyyking commented on Jul 3, 2018

    @hyyking
    Author

    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.

  5. k4pran commented on Jul 3, 2018

    @k4pran

    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().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions