# generating mazes using Eller's algorithm - why do I get loops?

I'm making a maze generator that uses Eller's algorithm. There's not much information about this particlar algorithm on the Internet. So I have some things misunderstood about it. I've made a picture to show you the proccess of generating an incorrect maze.

What should I do to avoid generating loops?

• I'm not sure what your question is, here. If the algorithm generates cycle-free mazes and you have a cycle, then isn't the answer just "implement it correctly"? – David Richerby Oct 4 '18 at 12:40
• @DavidRicherby as you can see in the image, I do everything those articles say. But anyway, sometimes I get loop. Sometimes I don't. – sovel2 Oct 4 '18 at 13:06

here I get two blocks of the same set, but they don't go one after the other. So I join the second one go it's own unique set

Don't do that; this is not a step mentioned in your first reference! Two cells are in the same set when there is already a path between them (by going up though the already generated portion). By arbitrarily placing the second block into a new set, you are ignoring the fact that it is connected to other cells.

When you leave the 3 blocks alone, you will get

(03 17)03
03(03 03)

You are required to place a wall between two blocks of the same set, because they already have a path between them. Thus you produce

03 03|03