This script uses a depth-first search algorithm to create a so called perfect maze.
Should be rather self-explainatory once you run the script.
A couple of things though.
The entrance and exit has deliberately been left out so you can set them at any point you wish.
Just delete the wall segment where you want your entrance/exit to be.
It might be a good idea to merge all the pieces together with the pathfinder tool and afterwards run the simplify command (found under Object->Path->Simplify...) with an Angle Threshold above 90º to remove any obsolete anchor points.
Hope you enjoy it as much as I did making it!