예제 #1
0
        public void ApplyQuantumMove(QuantumMove move)
        {
            bool applied       = false;
            var  new_harmonics = new List <QuantumHarmonic>();

            foreach (QuantumHarmonic harmonic in Harmonics_)
            {
                if (harmonic.Board.CheckQuantumMoveApplicable(move))
                {
                    // Passing to the superposition of the original and new harmonics
                    QuantumHarmonic new_harmonic = harmonic.Clone();
                    new_harmonic.Board.ApplyQuantumMove(move);
                    new_harmonics.Add(harmonic);
                    new_harmonics.Add(new_harmonic);
                    applied = true;
                }
                else
                {
                    // Keeping the original harmonic with degeneracy doubled
                    harmonic.Degeneracy *= 2;
                    new_harmonics.Add(harmonic);
                }
            }
            Harmonics_ = new_harmonics;
            UpdateQuantumCheckboard();
            AssertionException.Assert(applied, "Quantum move couldn't be applied on any harmonic");
        }
예제 #2
0
        private void RegroupHarmonics()
        {
            RemoveVanishing();
            AssertionException.Assert(Harmonics_.Count > 0, "Empty quantum superposition found");

            Harmonics_.Sort((a, b) => a.Board.GetHashCodeWithGameState().CompareTo(b.Board.GetHashCodeWithGameState()));
            var new_harmonics = new List <QuantumHarmonic>();

            QuantumHarmonic prev_harmonic = Harmonics_[0];

            for (int i = 1; i < Harmonics_.Count; i++)
            {
                if (Harmonics_[i].Board == prev_harmonic.Board)
                {
                    prev_harmonic.Degeneracy += Harmonics_[i].Degeneracy;
                }
                else
                {
                    new_harmonics.Add(prev_harmonic);
                    prev_harmonic = Harmonics_[i];
                }
            }
            new_harmonics.Add(prev_harmonic);

            Harmonics_ = new_harmonics;
            Harmonics_.Sort((a, b) => b.Degeneracy.CompareTo(a.Degeneracy));
        }