Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
 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());
 }
Ejemplo n.º 5
0
 public WFCCore(int outputWidth, int outputHeight, PatternManager patternManager, int maxIterations)
 {
     this.outputGrid     = new OutputGrid(outputWidth, outputHeight, patternManager.GetNumberOfPatterns());
     this.patternManager = patternManager;
     this.maxIterations  = maxIterations;
 }