Halite Home

Location is not fully useful... yet


In order to make hlt.Location a much more useful Class, it needs some basic stuff. I've added that. It should be patched to look like this:

class Location:
def __init__(self, x=0, y=0):
    self.x = x
    self.y = y

def __str__(self):
    return "Location({},{})".format(self.x, self.y)

def __repr__(self):
    return self.__str__()

def __eq__(self, other):
    """Override the default Equals behavior"""
    if isinstance(other, self.__class__):
        return self.__dict__ == other.__dict__
    return NotImplemented

def __ne__(self, other):
    """Define a non-equality test"""
    if isinstance(other, self.__class__):
        return not self.__eq__(other)
    return NotImplemented

def __hash__(self):
    """Override the default hash behavior (that returns the id or the object)"""
    return hash(tuple(sorted(self.__dict__.items())))


I think starter packages should be a minimal example of a bot that interfaces with the game engine. There are lots of things that would make the existing classes more useful, but this shouldn't be the goal of a starter package.


I like the equals and not equals operator overloading