# Can I randomly generate an endless road?

So suppose we stand on a position(x0, y0) of a map. We can only move on the horizontal plane(no jump and stuff) but we can move forward, left, or right (in a discrete math way, i.e. integer movement).

As soon as we move to the next position(x1, y1), everything around us is generated randomly by a program. We could be surrounded by one of mountain, lake, and road. We can only move on the road. The road is always 2D as the map itself.

My question is, are we able to play this game endlessly? "End" means that we come across a dead end and the only way out is to go backward.

• Do you want to program something like a "for of war" and randomize what's behind it when revealing it? Oct 19, 2012 at 19:46
• Your description is a little misleading. You say we can only move forward, left or right. Then say that the next position from (0,0) is (1,1). That indicates a diagonal move.
– House
Oct 19, 2012 at 19:50
• mvps.org/directx/articles/catmull here's one article that the guy explains how to use catmull rom splines, and for bonus, he gives a simulation where he generates an endless road with splines. don't know if this is exactly what you're looking for, but worth a look. Oct 19, 2012 at 20:09
• @GustavoMaciel Good link. I should note that I removed some important information when I edited the title. This is a discrete math type question. Essentially, tile based movement, not free movement. So splines don't apply in this situation. My fault, not yours.
– House
Oct 19, 2012 at 20:21
• So we are in a tile and we see the 8 tiles around us which can be walkable or non walkable. When we go to one of the walkable ones, are the 8 around it regenerated randomly (Meaning the tile we were previously can change) ? Or are the tiles we never saw the only ones that are generated? Cause if it is the first option the question doesn't make much sense.. You need to explain yourself better Oct 19, 2012 at 20:45