Randomly created maze arrays

I am interested in making a pac-manish game but I need to create a maze that is different every time. I’ve tried to take an old maze code I wrote in college but it uses vectors which I’d like to avoid (memory reasons) Could anyone point me in the right direction as to how do do this?

There are lots of different ways of doing it.

The Procedural Content Generation Wiki is full of them.
You might want to start with the Map Generation list.
There’s even a page specifically for Mazes.

When you say vectors do you mean C++ vectors or 2D/3D spatial vectors?

1 Like

C++ vectors. I have one example which works great as a stand-alone program but when put onto arduino it doesn’t give the same results.

standalone code: https://pastebin.com/7cKUyaCH
arduino code: https://pastebin.com/nmU9JFFa

(i haven’t had time to post on github yet)

You can just replace those with arrays if you have a good idea of
what the maximum size would be.


The reason the output wouldn’t be the same is that the code is using a random function to generate the output so even the same program wouldn’t be giving the same results every time.

Unless it’s differing in some other way?

in the arduino not only is the array not random; but it is the exact same every single time and it’s not just all 0 or all 1; it’s this every single time:

111111111
101010101
111111111
101010101
111111111
101010101
111111111
101010101
111111111

Then I would assume A1 isn’t sufficiently noisy.
(I’m not sure what A1 is on the Arduboy, I suspect it’s connected to something that is producing a steady input rather than noise.)

I’d recommend you try by using the Arduboy2 library which has an initRandomSeed() function which has been proven to be sufficiently random. It reads noise from an unconnected pin.

Some discussion that may be useful:

the only problem is I tried the same code on an arduino uno and arduino micro and both gave the same result; I even tried using different analog inputs. So puzzling. I’ll try initRandomSeed() though and see if that helps

The difference is (like I say) the Arduboy has some of its ports in use.

Checking the Arduboy2 source code I can see that A1 is the pin used for the right button, A0 is used for up, A2 is left and A3 is down.
So a lot of the analogue pins are already wired up to something, meaning they’ll most likely give out a reasonably steady input while in resting position.

The reason using analogue input works as a seed on other boards is because those pins aren’t wired up when you’re reading from them, so the values read are pure atmospheric noise.