コード例 #1
0
ファイル: CoreHelper.cs プロジェクト: f15h96/AI
        public bool CheckCellSolutionForCollision(Vector2Int cellCoordinates, OutputGrid outputGrid)
        {
            foreach (var neighbour in Create4DirectionNeighbours(cellCoordinates))
            {
                if (outputGrid.CheckIfValidPosition(neighbour.cellToPropagatePosition) == false)
                {
                    continue;;
                }
                HashSet <int> possibleIndicies = new HashSet <int>();
                foreach (var patternIndexAtNeighbour in outputGrid.GetPossibleValueForPosition(neighbour.cellToPropagatePosition))
                {
                    var possibleNeighboursForBase =
                        patternManager.GetPossibleNeighboursForPatternInDirection(patternIndexAtNeighbour,
                                                                                  neighbour.directionFromBase.GetOppositeDirectionTo());
                    possibleIndicies.UnionWith(possibleNeighboursForBase);
                }

                if (possibleIndicies.Contains(outputGrid.GetPossibleValueForPosition(cellCoordinates).First()) == false)
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #2
0
 public CoreSolver(OutputGrid outputGrid, PatternManager patternManager)
 {
     this.outputGrid        = outputGrid;
     this.patternManager    = patternManager;
     this.coreHelper        = new CoreHelper(this.patternManager);
     this.propagationHelper = new PropragationHelper(this.outputGrid, this.coreHelper);
 }
        public float CalculateEntropy(Vector2Int position, OutputGrid outputGrid)
        {
            float sum = 0;

            foreach (var possibleIndex in outputGrid.GetPossibleValueForPossition(position))
            {
                sum += patternManager.GetPatternFrequencyLog2(possibleIndex);
            }
            return(totalFrequencyLog - (sum / totalFrequency));
        }
コード例 #4
0
ファイル: WFCCore.cs プロジェクト: f15h96/AI
 public WFCCore(int outputWidth, int outputHeight, int maxIterations, PatternManager patternManager)
 {
     this.patternManager = patternManager;
     this.outputGrid     = new OutputGrid(outputWidth, outputHeight, patternManager.GetNumberOfPatterns());
     this.maxIterations  = maxIterations;
 }
コード例 #5
0
ファイル: CoreHelper.cs プロジェクト: f15h96/AI
 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());
 }