Test Scenario - lthengchun97/AStarSearch GitHub Wiki

From the A Star Search, we know that we need to search the shortest way to reach the ending point.

From the photo, we set our starting point as Sarawak , and the destination point as Melaka. We can see that there is 2 possible way to reach Melaka. Hence, we need to find the one best shortest way to reach that place.

First of all we need to find out the ideal distance. The ideal distance can be find as the formula,

d_ideal = sqrt(( ((current->data->x - end->data->x)(current->data->x - end->data->x)) + ((current->data->y - end->data->y)(current->data->y - end->data->y)) )

Then, we need to set an optimal distance for it,

 d_opt = d_ideal * 300%

Hence, we know that if the distance between the starting node to the next node is exceeding the d_opt will no be consider as a route to reach the final destination point.

So, the shortest way to reach the destination point from starting point will be:

  **Sarawak > Sabah > Melaka**

And also, the total distance travel along from Sarawak to Melaka also will be return correctly, it will not return the value which takes the longer distance one.