def __hash__(self):
        for i, state in enumerate(self.agentStates):
            try:
                int(hash(state))
            except TypeError as e:
                print e
                # hash(state)
        return (
            int((hash(tuple(self.agentStates)) + 13 * hash(self.food) + 113 *
                hash(tuple(self.capsules)) + 7 * hash(self.score)) % 1048575)
        )
Allows states to be keys of dictionaries.
dataset/ETHPy150Open rlpy/rlpy/rlpy/Domains/PacmanPackage/game.py/GameStateData.__hash__