Пример #1
0
        /// <summary>
        /// Applies a known shuffler to the table
        /// </summary>
        /// <remarks>
        /// The two numbers of the shuffler ID correspond to the positions of the bytes 0x00 and 0xFF in the unshuffled table.
        /// Using the known upper sub-table, the positions of these two values can be determined.
        /// </remarks>
        /// <param name="shufflerId">The shuffler ID of the known shuffler</param>
        private void ApplyShuffler(Solver.ShufflerId shufflerId)
        {
            Shuffler = Solver.GenerateShuffler(shufflerId.Pos1, shufflerId.Pos2, true);
            ApplyShufflerId(shufflerId.Pos1);
            ApplyShufflerId(shufflerId.Pos2);

            void ApplyShufflerId(int position)
            {
                int row = position >> 4;

                switch (UpperSubTable[row])
                {
                case 0:
                    Cells[position].Possible.RemoveAll(x => x != 0);
                    break;

                case 0xf:
                    Cells[position].Possible.RemoveAll(x => x != 0xff);
                    break;

                default:
                    throw new InvalidDataException("Incorrect position when setting shuffle table.");
                }
            }
        }
Пример #2
0
        public Table(Solver.ShufflerId shuffler, int upperSeed)
        {
            for (int i = 0; i < Seeds.Length; i++)
            {
                Seeds[i] = new PossibleBytes();
            }

            for (int i = 0; i < Cells.Length; i++)
            {
                Cells[i] = new PossibleBytes();
            }

            ApplyUpperSeed(upperSeed);
            ApplyShuffler(shuffler);

            RunCycles();
        }