예제 #1
0
        public Wave(int width, int height, List <Pattern> patterns, int patternSize,
                    double[,] image)
        {
            this.width       = width;
            this.height      = height;
            this.patterns    = patterns;
            this.patternSize = patternSize;

            this.image = image;

            lowestWeight  = getLowestWeight(patterns);
            highestWeight = getHighestWeight(patterns);

            superpositions = new Superposition[width, height];



            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    superpositions[i, j] = new Superposition(patterns);
                }
            }

            entropies    = new double[width, height];
            waveCollapse = new Pattern[width, height];

            // Sort all elements by the entropy
            OrderCellsListByEntropy();

            // Sort all elements that on the picture has lowe
            OrderCellsListByEntropyAndImage();
        }
예제 #2
0
        //private Wave wave;

        public Wave(int width, int height, List <Pattern> patterns, int patternSize)
        {
            this.width       = width;
            this.height      = height;
            this.patterns    = patterns;
            this.patternSize = patternSize;


            lowestWeight  = getLowestWeight(patterns);
            highestWeight = getHighestWeight(patterns);

            superpositions = new Superposition[width, height];


            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    superpositions[i, j] = new Superposition(patterns);
                }
            }

            entropies    = new double[width, height];
            waveCollapse = new Pattern[width, height];
            OrderCellsListByEntropy();
            UpdateEntropies();
        }
예제 #3
0
        // If another superposition has false value - set also false to this one
        public void OverlayWithAnother(Superposition superpositionToOVerlay)
        {
            for (int i = 0; i < coefficients.Length; i++)
            {
                if (coefficients[i] == true && superpositionToOVerlay.coefficients[i] == false)
                {
                    coefficients[i] = false;
                }
            }

            CalculateEntropy();
        }
예제 #4
0
        public Superposition(Superposition superposition)
        {
            this.patternFromSample = superposition.patternFromSample;

            // Copy coefficients.
            for (var i = 0; i < superposition.coefficients.Length; i++)
            {
                this.coefficients[i] = superposition.coefficients[i];
            }

            this.CalculateEntropy();
        }
예제 #5
0
        public Superposition(Superposition superposition, List <Pattern> patternFromSample)
        {
            this.patternFromSample = patternFromSample;

            coefficients = new bool[patternFromSample.Count];

            // Copy coefficients.
            for (var i = 0; i < superposition.coefficients.Length; i++)
            {
                this.coefficients[i] = superposition.coefficients[i];
                this.state           = superposition.state;
            }
            CalculateEntropy();
        }
예제 #6
0
        // Create Superposition in specified  overlapping location
        Superposition GetLocalSuperposition(int x, int y, List <Pattern> patternsFromSample)
        {
            Superposition superpositionForXY = new Superposition(patternsFromSample);

            for (var i = 0; i < patternsFromSample.Count; i++)
            {
                var candidate = patternsFromSample[i];
                if (!this.Overlaps(x, y, candidate))
                {
                    superpositionForXY.coefficients[i] = false;
                }
            }

            superpositionForXY.CalculateEntropy();
            return(superpositionForXY);
        }
예제 #7
0
        // Check the entropy after overlaying without changing the values
        public int CheckPossiblePatternsCount(Superposition superpositionToOverlay)
        {
            var fakeCoefficients = new bool[coefficients.Length];
            int patternCount     = 0;

            for (int i = 0; i < coefficients.Length; i++)
            {
                if (coefficients[i] == true && superpositionToOverlay.coefficients[i] == true)
                {
                    fakeCoefficients[i] = true;
                    patternCount++;
                }
            }

            return(patternCount);
        }