1
A *를 구현할 때 매우 유용했던 코드를 발견했습니다. 하지만 한 가지 문제에 직면 해 있습니다. 맨해튼 거리를 계산해야하는데 구현을 시도하지만 작동하지 않습니다. 이 코드는 유클리드 거리에 대한 계산을 제공합니다.유클리드 거리에서 맨하탄 거리로 변환 C#
public Node(Node parentNode, Node goalNode, int gCost,int x, int y)
{
this.parentNode = parentNode;
this._goalNode = goalNode;
this.gCost = gCost;
this.x=x;
this.y=y;
InitNode();
}
private void InitNode()
{
this.g = (parentNode!=null)? this.parentNode.g + gCost:gCost;
this.h = (_goalNode!=null)? (int) Euclidean_H():0;
}
private double Euclidean_H()
{
double xd = this.x - this._goalNode .x ;
double yd = this.y - this._goalNode .y ;
return Math.Sqrt((xd*xd) + (yd*yd));
}
코드가 C#으로 사용되었습니다. 대단히 감사합니다.
먼저 검색 내가 한 수 - 정확한 동일한 질문이 - http://stackoverflow.com/questions/4532528/manhattan-heuristic-function-for-a-star-a와 훌륭한 솔루션 .. –
나는 정말로 찾았지만 찾을 수 없었다. –