Пример #1
0
    def hash(self):
        """
            Returns the an `int` or a `long` representing hash
            of the current `Cell` instance. This is the same
            value that will be returned when the object is *hashed*
            through the python native **hash()** method.
        """
        if self._hash is None:
            self._hash = compute_hash(cell=self.number,
                                      player=self.player,
                                      mode=self.MODE)

        return self._hash
Пример #2
0
    def from_array(cls,array):
        verify_grid(array,mode=cls.MODE)
        grid_hash = sum([compute_hash(cell=c+1,player=p,mode=cls.MODE) for c,p in enumerate(array)])

        return cls(hash=grid_hash)