Search algorithm for maze (BFS and DFS)

Hi,

I’m trying to understand this code from the first lesson of the Harvard CS50 course on “Introduction to Artificial Intelligence with Python” . It’s a lesson about ‘Search’ and it describes the different methods of searching for the optimal solution to a maze problem. In the code below, it has the algorithms for Depth-First search and Breath-First search.

This is the link to the original code
https://cdn.cs50.net/ai/2020/spring/lectures/0/src0/maze.py

Edit: Forgot to add the link to the maze text files.
https://cdn.cs50.net/ai/2020/spring/lectures/0/src0/

On line 126, it creates an instance of the Node class like this:

start = Node(state=self.start, parent=None, action=None)

Can someone help me understand what does the argument of state=self.start refer to?
Does this self refer to the object ‘start’ (Node class) or the object ‘m’ (Maze class)?

I’m trying to re-write the code from scratch to better understand the flow and logic but when I try to run bits and pieces of it to test, I keep getting errors.

If I test it outside the Maze class and solve() function, I will get a NameError:
NameError: name ‘self’ is not defined

If I test it inside
AttributeError: ‘Maze’ object has no attribute ‘start’

I understand it is trying to create the very first node to start solving the maze problem. But the self has not been defined yet or has it?

This is the link to the course notes if it helps.
https://cs50.harvard.edu/ai/2020/notes/0/

Just went through the lines and found my answer.

self.start is actually defined inside the Maze constructor definition.
It is assigned the initial state of the maze (i, j).

Mods please close this if you’re watching. Thanks.