So ... I'm not familiar with path-finding algorithms, but is this the most efficient way to solve the problem?
I thought that was a pretty radical and creative algorithm... so I coded it up
val res = Seq(x-1,x,x+1).map( a => Seq(y-1,y,y+1).map( b=> (a,b))).flatten
.filterNot( ab => ab._1 == x && ab._2 == y) // don't include me
.filterNot( ab=> ab._1 < leftTop._1 || ab._1 > rightBottom._1) // don't include points outside the maze
.filterNot( ab=> ab._2 < leftTop._2 || ab._2 > rightBottom._2)
.filterNot( ab=> path.contains(ab)) // don't revisit points along your path
Now if you add 1 more filter, literally 1 more line of code, to eliminate paths that are prohibited because they intersect with a barrier, you are good to go.
a room is simply a maze with zero barriers.