I searched and even visited a maze-algorithm-collecting website, but nothing satisfies the following statements I require.
To make it clear, I need an infinite maze generating algorithm that:
- makes a
perfect maze, which is to say,2d,grid-based- each square is space/wall
- every 2 spaces are linked and there's only one path
- no 2x2 square is all space/wall
- provides an
f(s,x,y), wheresis used forrandom seedor something like this- returns type of square at (x,y)
- for different
swithin 0~(32768 or something), gives different results
- infinite (probably limited by 64-bit int though)
- extra space (I mean in program) is allowed
Clarification:
- meaning of infinite here: something like this
function f(s,x,y){
// for each x,y it gives a result, so we consider it "infinite"
return (s*x+y)%32768<30 ? "wall" : "space";
}
- this is a finite algorithm (satisfies 1)
init:all walls
choose a square,flag it and add to list
while(list not empty)
{
chose randomly from list
delete from list
if(there's a flag)
{
delete it
continue
}
make a flag
if(surrounding wall num≤1)
{
add 4 surrounding walls to list
}
}
- something satisfies 1 and 3
we start from the Eller's Algorithm
it is generated row by row, and saves a set of regions
first row:all regions into a set,wall between regions(randomly)
while(not last row){
foreach(neighbour regions){
if(not in the same set){
break their wall and merge the regions(randomly)
}
}
foreach(region){
break the wall below(randomly,and at least one does this)
}
generate next row
for this row:{
foreach(region){
if(connected with above){
merge to prev-set
}
}
throw away prev-prev-set
}
}
last row:connect all regions that are not in the same set
If we start from the centre and generate it circle by circle, it can be infinite; sadly we have rule 2.



