import pickle
import logging


def save_perceptions( ilc_perceptions : list, is_file_name : str ) -> bool:
    """save a game state to file
    Args:
        ilc_perceptions (list(Game)): perceptions to be saved
        is_file_name (str): destination file name 
    Returns:
        bool: false: success | true: fail
    """
    
    try:
        with open(is_file_name, "wb") as opened_file:
            pickle.dump( ilc_perceptions, opened_file )

    except OSError as problem:
        logging.critical(f"Pickle: {problem}")
        return True

    return False