public CoreSolver(OutputGrid outputGrid, PatternManager patternManager) { this.outputGrid = outputGrid; this.patternManager = patternManager; coreHelper = new CoreHelper(this.patternManager); this.propagationHelper = new PropagationHelper(this.outputGrid, this.coreHelper); }
public float CalculateEntropy(Vector2Int position, OutputGrid outputGrid) { float sum = 0; foreach (var possibleIndex in outputGrid.GetPossibleValuesForPositon(position)) { sum += patternManager.GetPatternFrequencyLog2(possibleIndex); } return(totalFrequencyLog - (sum / totalFrequenc)); }
public bool CheckCellSolutionForCollision(Vector2Int cellCoordinates, OutputGrid outputGrid) { foreach (var neighbour in Create4DirectionNeighbours(cellCoordinates)) { if (outputGrid.CheckIfValidPosition(neighbour.CellToPropagatePosition) == false) { continue; } HashSet <int> possibleIndices = new HashSet <int>(); foreach (var patternIndexAtNeighbour in outputGrid.GetPossibleValueForPossition(neighbour.CellToPropagatePosition)) { var possibleNeighboursForBase = patternManager.GetPossibleNeighboursForPatternInDirection(patternIndexAtNeighbour, neighbour.DirectionFromBase.GetOppositeDirectionTo()); possibleIndices.UnionWith(possibleNeighboursForBase); } if (possibleIndices.Contains(outputGrid.GetPossibleValueForPossition(cellCoordinates).First()) == false) { return(true); } } return(false); }
public List <VectorPair> CheckIfNeighboursAreCollapsed(VectorPair pairToCheck, OutputGrid outputgrid) { return(Create4DirectionNeighbours(pairToCheck.CellToPropagatePosition, pairToCheck.BaseCellPosition) .Where(x => outputgrid.CheckIfValidPosition(x.CellToPropagatePosition) && outputgrid.CheckIfCellIsCollapsed(x.CellToPropagatePosition) == false) .ToList()); }
public WFCCore(int outputWidth, int outputHeight, PatternManager patternManager, int maxIterations) { this.outputGrid = new OutputGrid(outputWidth, outputHeight, patternManager.GetNumberOfPatterns()); this.patternManager = patternManager; this.maxIterations = maxIterations; }