Esempio n. 1
0
        private void PropagateNeighbour(VectorPair propagatePair)
        {
            var possibleValuesAtNeighbour = outputGrid.GetPossibleValueForPossition(propagatePair.CellToPropagatePosition);
            int startCount = possibleValuesAtNeighbour.Count;

            RemoveImpossibleNeighbours(propagatePair, possibleValuesAtNeighbour);

            int newPossiblePatternCount = possibleValuesAtNeighbour.Count;

            propagationHelper.AnalyzePropagationResults(propagatePair, startCount, newPossiblePatternCount);
        }
        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));
        }
        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);
        }