Exemple #1
0
        public QuantumPiece GetQuantumPiece(Position pos)
        {
            Piece?piece = null;
            ulong filled = 0, empty = 0;

            foreach (QuantumHarmonic harmonic in Harmonics_)
            {
                Piece?classical = harmonic.Board[pos];
                if (classical.HasValue)
                {
                    AssertionException.Assert(piece == null || piece == classical,
                                              $"The square {pos} appears in a superposition of two pieces");
                    piece   = classical;
                    filled += harmonic.Degeneracy;
                }
                else
                {
                    empty += harmonic.Degeneracy;
                }
            }
            if (piece.HasValue)
            {
                return(new QuantumPiece(piece, MeasurementUtils.Probability(filled, filled + empty)));
            }
            else
            {
                return(new QuantumPiece(null, 1.0));
            }
        }