import copy
# ==========================================
# GLOBAL SETTINGS
# ==========================================
# This value represents a building. Buildings are climate-controlled 
# and do not participate in the heat diffusion of the city.
# You should use this constant in your implementations as it could be changed during tests. 
BUILDING_VALUE = None
# Thermal properties dictionary


# ==========================================
# STUDENT IMPLEMENTATION
# ==========================================

def initialize_city(land_cover_grid, thermal_props):
    """
    Converts a grid of characters into a grid of temperatures.
    
    Inputs:
        land_cover_grid (list of list of str): A 2D grid of characters ('A', 'B', 'G', 'W').
        thermal_props (dict): A dictionary mapping characters to float temperatures.
        
    Returns:
        list of list of float/None: A new 2D grid where 'B' is replaced by BUILDING_VALUE in the thermal_props,
                                   and other characters are replaced by their thermal values.
    """
    pass

def get_avg_temp(temp_grid):
    """
    Calculates the average temperature of the outdoor areas of the city.
    
    Inputs:
        temp_grid (list of list): The temperature grid.
        
    Returns:
        float: The mean temperature of all cells that are NOT buildings.
    """
    pass

def get_valid_neighbors(temp_grid, row, col):
    """
    Finds all valid thermal neighbors (8 directions) for a given cell.
    
    Inputs:
        temp_grid (list of list): The current temperature grid.
        row (int): Row index of the cell.
        col (int): Column index of the cell.
        
    Returns:
        list: A list of temperatures (floats) from valid, non-building neighbors.
    """
    pass

def apply_diffusion(temp_grid):
    """
    Simulates one step of heat diffusion across the city using the Moore Neighborhood (8 neighbors).
    
    Calculate the new temperature using a 50/50 weighted average:
    New Temp = (0.5 * Current Temp) + (0.5 * Average of Valid Neighbors)
    
    Inputs:
        temp_grid (list of list): The current temperature grid.
        
    Returns:
        list of list: A NEW 2D grid containing the updated temperatures.
    """
    pass


def add_green_infrastructure(temp_grid, cooling_points):
    """
    Applies local cooling effects (e.g., planting trees) to specific coordinates.
    
    Inputs:
        temp_grid (list of list): The temperature grid
        cooling_points (list of tuples): A list of (row, col, strength) representing 
                                         where to apply cooling and by how many degrees.
    
    Returns:
        list of list: A NEW 2D grid containing the updated temperatures.
    """
    pass


def generate_shadow_mask(land_cover_grid, sun_direction, shadow_length):
    """
    Creates a mask of 1s (sun) and 0s (shadow) based on building positions.
    
    Inputs:
        land_cover_grid: The original char grid.
        sun_direction: String ('N', 'S', 'E', 'W') representing where the sun is located.
                       Note: If sun is in North, shadow goes South ('S').
        shadow_length: Integer, how many cells the shadow extends.
        
    Returns:
        2D list of floats (1.0 for sun, 0.0 for shadow).
    """
    pass


def apply_solar_heating(temp_grid, shadow_mask, solar_intensity=1.0):
    """
    Adds heat to cells that are not in shadow.
    
    Inputs:
        temp_grid: The temperature grid.
        shadow_mask: The 2D grid of 1s and 0s.
        solar_intensity: How many degrees to add to sun-exposed cells.

    Returns:
        list of list: A NEW 2D grid containing the updated temperatures.
    """
    pass
