def compute_hash(cell,player,mode=TTT_3_IN_A_ROW): verify_player(player=player) verify_cell(cell=cell,mode=mode) bits_to_push = (cell * 3) - 3 return (1 << player + bits_to_push)
def create_and_verify_cell(number,player,cell_class): verify_player(player=player) verify_cell(cell=number,mode=cell_class.MODE) ref_key = '{}-{}'.format(number,player) cell = cell_class._Refs.get(ref_key,None) if cell is None: cell = create_new_cell(cell_cls=cell_class,number=number,player=player) cell_class._Refs[ref_key] = cell cell_class._Hashes[cell.hash] = cell_class._Refs[ref_key] return cell
def get_cell(self,number): verify_cell(cell=number,mode=self.MODE) return self._cells[number-1]