how to create a route between many paths

Questions:

I was trying to make a route from a starting point(green) to a finishing point(red) as shown in the photo below.

enter image description here

I’ve made one random algorithm to make the route,
also a list with connected vertices to each vertex. like,, [a] connected to points(c,d)

path = list of points(x,y),
#path =10
s_point = get starting point(x,y)
end_Point = get end point(x,y)
for(int i=0;i<=#paths;i++){
    path.add(s_point)
    checked_points.add(s_point)
    next_point = s_point
    while(next_point.not_equals(end_point)){
        _point[] = get points connected to (next_point)
        while(_point[random()].not checked){
            path.add(_point[random()])
            next_point = _point[random()]
        }
    }
}
get_use_of_the_shortest_path()

so, the question is,
how to replace the random method, to a method that should guide the path directly to the end point (considering the different paths available)??? or any information regarding how to make a route algorithms.

ex2,

Answers:



Need Help? Chat with us