static void Propogate(Tile[,] map, int fromX, int fromY) { var tile = map[fromX, fromY]; foreach (Direction dir in DirectionUtils.Directions()) { bool?valueInDir = tile.Get(dir); if (valueInDir == null) { continue; } (Tile neighbor, int neighborX, int neighborY) = map.ValueInDirection(fromX, fromY, dir); if (neighbor != null) { if (neighbor.TryResolve(dir.Opposite(), valueInDir.Value)) { Propogate(map, neighborX, neighborY); } } } }