Maze generation with Kruskal's algorithm

Поделиться
HTML-код
  • Опубликовано: 13 сен 2024
  • How to generate a maze with Kruskal's method.
    github.com/fer...

Комментарии • 14

  • @talkingscribe8898
    @talkingscribe8898 Год назад +32

    What prevents this from creating loops? How does it ensure that there is a solid path from start to end?

    • @CatoSierraWasTaken
      @CatoSierraWasTaken Год назад +15

      Kruskal's algorithm finds a specific kind of tree, a tree being a connected network that has no loops and a designated root node, so every point will be connected to every other, and there won't be any loops.

    • @regularsalamander
      @regularsalamander Год назад +7

      @@CatoSierraWasTaken trees don't need a designated root node. you can take any tree and change which node is the root and it'll still be a tree (though it might not have the same properties)

    • @asdfghyter
      @asdfghyter Год назад +1

      @@CatoSierraWasTaken how does it do that?

    • @CatoSierraWasTaken
      @CatoSierraWasTaken Год назад +16

      @@asdfghyter The algorithm starts by treating every node as a separate tree. Every time it looks for a new edge, it only accepts ones that connect two different trees, then updates the list of trees to replace the two old trees with the single tree formed by connecting them.

  • @killmeister2271
    @killmeister2271 Год назад +3

    fascinating; this appears to be easy to code too

  • @atreidesson
    @atreidesson Год назад +2

    Why don't they circle?

    • @chrishunter1109
      @chrishunter1109 Год назад +2

      because lines

    • @atreidesson
      @atreidesson Год назад +1

      @@chrishunter1109 I meant, not "circles" but "circle"

    • @CatoSierraWasTaken
      @CatoSierraWasTaken Год назад +1

      having no loops is a guarantee of the algorithm used (Kruskal's algorithm)

    • @atreidesson
      @atreidesson Год назад

      @@CatoSierraWasTaken Oh, that looked like almost random stitches

    • @lanceraltria
      @lanceraltria Год назад

      @@atreidesson Kruskal's algorithm only creates a stitch if the stitch would connect two "parts" that are not already connected, which guarantees the no-loop condition

  • @beko96batu
    @beko96batu Год назад +1

    is this loss?