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(); }
//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(); }
// 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(); }
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(); }
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(); }
// 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); }
// 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); }