DEV Community

Discussion on: A Star (A*) Path Finding C++

Collapse
 
tambora profile image
Rohan Behl

I'm surprised no one mentioned this but your algorithm is whack. you need to give the diagonal movements a higher movement cost.

if(newX == newY){
gNew = node.gCost + 1.414;
} else {
gNew = node.gCost + 1.0;
}