private void PropagateNeighbours(VectorPair propagatePair) { var possibleValuesAtNeighbour = outputGrid.GetPossibleValuesForPositon(propagatePair.CellToPropagatePosition); int startCount = possibleValuesAtNeighbour.Count(); RemoverImpossibleNeighbours(propagatePair, possibleValuesAtNeighbour); int newPossiblePatternCount = possibleValuesAtNeighbour.Count; propagationHelper.AnalyzePropagatonResults(propagatePair, startCount, newPossiblePatternCount); }
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 CheckCellSOlutionForCollisions(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.GetPossibleValuesForPositon(neighbour.CellToPropagatePosition)) { var possibleNeighborusForBase = patternManager.GetPossibleNeighboursForPatternInDIrection(patternIndexAtNeighbour, neighbour.DiectionFromBase.GetOppositeDirectionTo()); possibleIndices.UnionWith(possibleNeighborusForBase); } if (possibleIndices.Contains(outputGrid.GetPossibleValuesForPositon(cellCoordinates).First()) == false) { return(true); } } return(false); }