예제 #1
0
        public bool TryGetPermutation(byte *output, out uint permutationHash)
        {
            for (; currentRow < 4; currentRow++)
            {
                for (; currentColumn < 4; currentColumn++)
                {
                    if (grid[currentRow * 4 + currentColumn] == 0)
                    {
                        GridFunctions.CloneGrid(collapsedGrid, output);
                        GridFunctions.CloneRow(grid + rowDelta * currentRow + offset, output + rowDelta * currentRow + offset, columnDelta);

                        output[currentRow * 4 + currentColumn] = 1;
                        GridFunctions.collapseRow(output + rowDelta * currentRow + offset, columnDelta);

                        uint rowHash = GridFunctions.GetRowHash(output + rowDelta * currentRow + offset, columnDelta);
                        rowHash       <<= 2;
                        rowHash        |= (uint)currentRow;
                        permutationHash = rowHash;

                        currentColumn++;
                        return(true);
                    }
                }

                currentColumn = 0;
            }

            permutationHash = 0;
            return(false);
        }