I need to generate a simple random path in 2D tile map. An input parameter is a number of steps. The condition is that each tile has just two adjacent tiles on the path so there are no rooms and no crossroads.
I was looking for some solution on the net and I didn't find anything like this. Drunkard algorithm makes rooms and everything else is maze generation algorithms. Maybe I am not searching by proper keywords.
The important thing is randomness as I need the path completely different every time.
Edit: adding sample image
sample path:
the main feature is that each tile has just 2 neighbors.
Improved version of this would be using specific target tile as the end of the path and minimum and maximum of steps but that's not so important right now.
Thank you for any idea.
create 2D map
so create 2D array of the size of your map and clear it by for example 0
add N
random obstacles
for example filled circles in the map
use A* to find shortest path
you can use mine ... C++ A* example
If you want something more complex then you can create random terrain and use A* to find shortest path (while going up will cost more then going down ...). To create random terrain you can use:
which can be use also used for random map generation...