Depth First Search (DFS) in Python [Python Maze World- pyamaze]

Sdílet
Vložit
  • čas přidán 4. 07. 2024
  • Python Maze World
    In this series we will learn about different Maze Search Algorithm in Python e.g., Depth First Search (DFS), Breadth First Search (BFS), A-Star Search, Dijkstra's Algorithm and many other possible search and navigation algorithms like Wall Following Robot, Reinforcement Learning, Genetic Algorithm etc.
    This video is about Depth First Search (DFS).
    (00:00) Intro
    (00:32) Graph, Maze and Tree
    (02:48) DFS and BFS
    (06:23) What is Stack
    (07:36) Pseudocode of DFS
    (12:07) DFS Implementation in Python
    ⭐⭐Breadth First Search (BFS) Implementation:
    • Breadth First Search (...
    ⭐⭐A-star (A*) Search Implementation:
    • A-Star A* Search in Py...
    ⭐⭐Comparison of DFS, AFS and A*
    • DFS BFS and A* Search ...
    ⭐⭐Dijkstra's Algorithm:
    • Dijkstra Shortest Path...
    You can download the package as:
    pip install pyamaze
    Or you can copy the module code from here:
    github.com/MAN1986/pyamaze/bl...
    The used demo file is here :
    github.com/MAN1986/pyamaze/tr...
    How to use pyamaze module:
    • Maze Generation and Se...
    What is __name__=='__main__':
    • [Python Programming Ba...
    Here is the Playlist:
    • AI Search Algorithms u...
    #Python #pyamaze #Python

Komentáře • 55

  • @bitnewt
    @bitnewt Před 11 dny

    This was explained perfectly. The graphics and animations were really useful!

  • @dallasdominguez9501
    @dallasdominguez9501 Před 2 lety +1

    An excellent video my friend. I learned so much! Thank you for such a high quality lesson.

  • @malibaturhan
    @malibaturhan Před měsícem

    Thank you this is really convenient and brain friendly explanation

  • @abdallhelmasry4108
    @abdallhelmasry4108 Před 10 měsíci +1

    man this is the most usfull video explaining the algorithm thank you❤❤

  • @ahmedhadwan9273
    @ahmedhadwan9273 Před 2 lety

    This was very helpful. Thank you

  • @CKGameplay
    @CKGameplay Před 2 lety

    Amazing Job, Thank you so much

  • @duboef
    @duboef Před 2 lety +1

    Great explanation! Appreciate it

  • @aczsair
    @aczsair Před rokem +2

    thanks a lot, I understood DFS by your video. Esselamu aleykum.

    • @LearningOrbis
      @LearningOrbis  Před rokem +1

      Walaikum Assalam.

    • @aczsair
      @aczsair Před rokem

      @@LearningOrbis how can I transform DFS to maze labrynt robot witn ardunio..ı need algorıthm scheme like your wall follower video.

  • @YankyFonteBoa
    @YankyFonteBoa Před rokem

    I would like your implementation to show the generated nodes and visited nodes and also the depth when live, could you tell me how to do it?

  • @bishoysameh4923
    @bishoysameh4923 Před 2 lety +1

    this was really well explained in an organized manner, thank you

    • @LearningOrbis
      @LearningOrbis  Před 2 lety +1

      You're very welcome!

    • @bishoysameh4923
      @bishoysameh4923 Před 2 lety

      @@LearningOrbis can you tell me how to get the final path (for DFS or BFS)in a matrix form, thanks in advance

    • @LearningOrbis
      @LearningOrbis  Před 2 lety +1

      By default, without using any algorithm, the pyamaze module gives the path as a dictionary. Moreover the algorithms I coded also calculate the path as sickbay. And you want that as a list.
      This is not done in pyamaze module but can be done easily as explained below:
      👉 m.path gives the path as Dictionary (m is maze).
      👉 Create an empty list (e.g. pathList) for the path as a list. And then add the start cell in that list which is (m.rows,m.cols) by default.
      👉 Search for the key (m.rows,m.cols) inside the dictionary m.path and append its value (let's say cell V) in pathList.
      👉 Search for the key V inside the dictionary m.path and append its value in pathList.
      👉 Repeat the last two steps until the goal cell (1,1) is appended in the list.
      Let me know if you have any question.

    • @bishoysameh4923
      @bishoysameh4923 Před 2 lety

      @@LearningOrbis but I want the path of the BFS and DFS as the maze has multiple paths not a single one

    • @LearningOrbis
      @LearningOrbis  Před 2 lety

      The BFS and DFS functions return the path as dictionary. And then you can apply the above described logic on that dictionary to convert that to list. Does that what you are looking for?

  • @pedromuniz1858
    @pedromuniz1858 Před 6 měsíci

    how do i deal with looping in the maze, like a corner where it always turns left ?

  • @lunaticclips4554
    @lunaticclips4554 Před měsícem

    thanks for explaining , i have a doubt :
    is the order of direction while looping is necessary in case of bfs as well??

  • @xphn1985
    @xphn1985 Před 10 měsíci

    Thank you so much for this nice work!!!!

    • @LearningOrbis
      @LearningOrbis  Před 10 měsíci +1

      You're very welcome!

    • @xphn1985
      @xphn1985 Před 10 měsíci

      @@LearningOrbis I am watching the other two tutorials on BFS and dijkstra search now. Thanks again for your detailed and patient demonstration:)

    • @LearningOrbis
      @LearningOrbis  Před 10 měsíci

      Thanks for the compliment :)

  • @yasminzamrin
    @yasminzamrin Před 2 lety

    this is very ell explained! How would i implement an iterative deepening depth first search? From my understanding I would need a depth counter. I'm new to python and would really appreciate some help!

    • @LearningOrbis
      @LearningOrbis  Před 2 lety

      Thanks.
      DFS uses a stack and BFS uses a queue. IDDFS uses primarily the DFS approach but it puts a limit on maximum depth and after that, it searches in Breadth.
      I will try to develop its logic but after a couple of weeks. You can try it and share the result with me.

    • @syedtalha1264
      @syedtalha1264 Před 4 měsíci

      @@LearningOrbis Have you had the chance to do it?

  • @RahulSharma-by7nz
    @RahulSharma-by7nz Před 2 lety

    good

  • @rasikaburde5468
    @rasikaburde5468 Před 4 měsíci

    How do we get the csv file, is it like hardcoded?

    • @LearningOrbis
      @LearningOrbis  Před 4 měsíci

      Code can generate a random maze and we can Export that maze as CSV file. Later we can load that CSV file if we want to work on the same maze.
      Please watch the first video in playlist:
      czcams.com/video/McMU-WuJwG0/video.html

  • @71-taherbhurka62
    @71-taherbhurka62 Před 4 měsíci

    the code for dfs is not working , its showing that it cannot find the key value

    • @LearningOrbis
      @LearningOrbis  Před 4 měsíci

      Have you tried this code:
      github.com/MAN1986/pyamaze/tree/main/Demos/DFS

  • @ceydaavc4978
    @ceydaavc4978 Před rokem

    can we implement this code to java?ı mean ı want to create a random maze with java but ı cant find any resource to learn that

    • @LearningOrbis
      @LearningOrbis  Před rokem

      Of course we can but there is no direct way. I have provided the GitHub link to code and you need to understand that and implement the same in Java

  • @jimmyloluolajide7777
    @jimmyloluolajide7777 Před 2 lety

    Very informative. Thanks for sharing. Please, I have a question relating to this topic and would like to contact you. How do I reach you? Thanks

    • @LearningOrbis
      @LearningOrbis  Před 2 lety

      Thanks.
      You can contact me at mahsan.naeem@gmail.com

  • @xy4611
    @xy4611 Před rokem

    What if middle of the map is the starting node?

    • @LearningOrbis
      @LearningOrbis  Před rokem

      This should work.
      You can set the starting point as any cell. Please watch this video for detail: czcams.com/video/McMU-WuJwG0/video.html

  • @user-wo3ki1yl7w
    @user-wo3ki1yl7w Před 7 měsíci

    bro code is not working help me out.

  • @ghoritauheed7182
    @ghoritauheed7182 Před rokem

    very well eplained but can you make this same playlist but without using the "maze" for the explanation... im having hard time merging these two together because in my academics only graphs are mentioned.... please..................................make one without mazes....

    • @LearningOrbis
      @LearningOrbis  Před rokem +1

      I have explained the relation between Maze and Graph. It will be very hard to design new GUI and graphics for Graph.

    • @ghoritauheed7182
      @ghoritauheed7182 Před rokem

      @@LearningOrbis 🥲 Noo no like that.. i wan you to explain it using python dictionary like A node has b & c like that... No need of new gui