human
I am working on the file ".ipynb_checkpoints/csp-checkpoint.ipynb".
The first task is:
Helper Functions
We will now implement few helper functions that will help us visualize the Coloring Problem. We will make some modifications to the existing Classes and Functions for additional book keeping. To begin with we modify the assign and unassign methods in the CSP to add a copy of the assignment to the assingment_history. We call this new class InstruCSP. This would allow us to see how the assignment evolves over time.
Can you write Python program for it?
assistant
#Here is the Python program you requested.

import copy
class InstruCSP(CSP):
    
    def __init__(self, variables, domains, neighbors, constraints):
        super().__init__(variables, domains, neighbors, constraints)
        self.assingment_history = []
        
    def assign(self, var, val, assignment):
        super().assign(var,val, assignment)
        self.assingment_history.append(copy.deepcopy(assignment))
    
    def unassign(self, var, assignment):
        super().unassign(var,assignment)
        self.assingment_history.append(copy.deepcopy(assignment))