Beispiel #1
0
        public string ScrambleState(int seed, int iterations)
        {
            Random rng = new Random(seed);

            int[,] newState = (int[, ])CurState.Clone();

            for (int i = 0; i < iterations; i++)
            {
                switch (rng.Next(5))
                {
                case 0:
                    SwapBigColumn(newState, rng.Next(SizeC / SquareSizeC), rng.Next(SizeC / SquareSizeC));
                    break;

                case 1:
                    SwapBigRow(newState, rng.Next(SizeR / SquareSizeR), rng.Next(SizeR / SquareSizeR));
                    break;

                case 2:
                    SwapValues(newState, rng.Next(SquareSizeR * SquareSizeC) + 1, rng.Next(SquareSizeR * SquareSizeC) + 1);
                    break;

                case 3:
                    MirrorBigColumn(newState, rng.Next(SizeC / SquareSizeC));
                    break;

                case 4:
                    MirrorBigRow(newState, rng.Next(SizeR / SquareSizeR));
                    break;
                }
            }
            string res = $"0;0.0;{SizeR};{SizeC};{SquareSizeR};{SquareSizeC};";

            for (int i = 0; i < SizeR; i++)
            {
                for (int j = 0; j < SizeC; j++)
                {
                    res += (newState[i, j] == 0 ? "." : $"{newState[i, j]}") + (j >= SizeC - 1 && i >= SizeR - 1 ? "" : " ");
                }
            }
            return(res);
        }