Example #1
0
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)
Example #2
0
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
Example #3
0
    def get_cell(self,number):

        verify_cell(cell=number,mode=self.MODE)
        return self._cells[number-1]