Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a constructor __init__(self, depth_limit) that constructs a new Searcherob

ID: 3720423 • Letter: W

Question

Write a constructor __init__(self, depth_limit) that constructs a new Searcherobject by initializing the following attributes:

an attribute states for the Searcher‘s list of untested states; it should be initialized to an empty list

an attribute num_tested that will keep track of how many states the Searcher tests; it should be initialized to 0

an attribute depth_limit that specifies how deep in the state-space search tree the Searcher will go; it should be initialized to the value specified by the parameter depth_limit.  
(A depth_limit of -1 will be used to indicate that the Searcher does not use a depth limit.)

Because we’ve already given you an __repr__ method for the class, you should be able to test your constructor as follows:

Explanation / Answer

Constructor Function:

   #Parametrized Constructor
def __init__(self, height, width):
  
       #Initializing the attribute width
       self.width = width;
  
       #Initializing the attribute height
       self.height = height;
      
       #Initializing the attribute slots with ' ' character
self.slots = [[' '] * self.width for row in range(self.height)];

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote