Example #1
0
        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);
        }
Example #2
0
        private void PropagateNeighbour(VectorPair propagatePair)
        {
            var possibleValuesAtNeighbour =
                outputGrid.GetPossibleValueForPosition(propagatePair.cellToPropagatePosition);
            int startCount = possibleValuesAtNeighbour.Count;

            RemoveImpossibleNeighbours(propagatePair, possibleValuesAtNeighbour);

            int newPossiblePatternCount = possibleValuesAtNeighbour.Count;

            propragationHelper.AnalyzePropagationResults(propagatePair, startCount, newPossiblePatternCount);
        }
Example #3
0
        public float CalculateEntropy(Vector2Int position, OutputGrid outputGrid)
        {
            float sum = 0;

            foreach (var possibleIndex in outputGrid.GetPossibleValueForPosition(position))
            {
                totalFrequency += patternManager.getPatternFrequency(possibleIndex);
                sum            += patternManager.getPatternFrequency2(possibleIndex);
            }
            totalFrequencyLog = Mathf.Log(totalFrequency, 2);

            return(totalFrequencyLog - (sum / totalFrequency));
        }