I'm trying to write a function that finds a path within a 2D grid, so that every square is visited but only once. Just four directions of travel (n,s,e,w or u,d,l,r if you like) no diagonals. So far I got it to work on a small grid 5 by 5, but as the grid size increases so the random trial and error method begins to fail. I used a method that looks beyond the current available move, to look ahead at best next move before choosing a direction to go, this helped a little but still no result.
Has anyone seen anything relating to this, I've searched a bit, but don't know if there is a name for this kind of pathfinder.
|