Re:500,000 clones get you out of a 10x10 maze
by carb on Thursday December 13, 2012 @03:59PM
(#4918053)
So it's more of a 10x10 room than a 10x10 maze?
[ Parent
| on HN ]
Re:500,000 clones get you out of a 10x10 maze
by dxbydt on Thursday December 13, 2012 @05:29PM
(#4918504)
adding barriers to make a room into a maze is trivial. So if you were forking my scala code, you see 4 filters -
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.