CONTENTS: (A) the solution to the was_influenced_by question in class (B) a convenience method to add to Trial (C) instructions for how to check that was_influenced_by works. This assumes that you have complete working code for node.py and trial.py, and added the nodeat method to class Trial (A) This method is to be placed in your definition of class Node, as the last method there. The graders would strongly prefer that you not have it to your CMS submission, though, so that it's easier for them to find what they are expecting. # This method is from lecture; it's not to be graded def was_influenced_by(self, oldone): """Returns: True if self is in oldone's legacy and this node is actually converted, False otherwise Pre: oldone is a node that is not this one.""" # Do a recursive implementation that doesn't do caching or # require having computed legacies, for lecture purposes. # Let's not do tricks about whether the generation numbers # satisfy the usual preconditions of trials, etc. if not self.is_converted() or self.contacted_by == []: return False elif oldone in self.contacted_by: return True else: for contacter in self.contacted_by: if contacter.was_influenced_by(oldone): return True # If we get to this line, no contacter was influenced by oldone return False (B) This method is to be placed in your definition of class Trial, as the last method there. The graders would strongly prefer that you not have it to your CMS submission, though, so that it's easier for them to find what they are expecting. This method is just for convenience and readability. def nodeat(self,gen,genind): """Returns: node (gen,genind). Pre: (gen,genind) is a valid node in this trial.""" return self.nodelist[gen][genind] (C) Here's the kind of thing you can do to test your was_influenced_by. In Python Interactive Mode, import trial t = trial.Trial(...) # insert appropriate parameters; # trial.Trial(g=10,n=8,c=6,d=3,t=2) seemed like a good # choice t.run() trial.showit(t) # Then use ctrl-c (on a mac) to wrest control back from the visualizer. I # usually end up hitting it a couple of times just to make sure. # Doing ctrl-c instead of clicking the little red close button # makes sure that the window stays open so you can see it while you # check your code's results. t.nodelist[2][1].was_influenced_by(t.nodelist[0][0]) # You'll get an answer True/False, which you can check the accuracy of t.nodelist[2][1].was_influenced_by(t.nodelist[0][2]) #Ditto and etc.