full problem: https://www.chegg.com/homework-help/questions-and-answers/order-se
ID: 3716458 • Letter: F
Question
full problem: https://www.chegg.com/homework-help/questions-and-answers/order-see-full-solution-e-sequence-moves-initial-state-goal-state-need-add-method-state-cl-q28747560
Convert pseudocode to python. Just simply convert it doesnt have to be exact. I can fix the rest if not exactly correct
def print_moves_to(self):
if self is the initial state: # base case
print('initial state:')
print the board associated with self
else:
make a recursive call to print the moves to the predecessor state
print the move that led to self (see format below)
print the board associated with self?
Explanation / Answer
def print_moves_to(self): # the initial state previous state must be None to terminate the program if self.previous_state is None: print('initial state:') print(self.board) else: self.previous_state.print_moves_to() # let's print the move print(self.previous_state.move) # let's print the board print(self.previous_state.board) # let me know if you have any query. from the information, # I was able to do the above. I hope, I helped you.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.