A*算法程式相关

这段时间比较忙,所以这里没有新东西。今天开始继续研究A*,准备开始向算法学进军,为C++游戏开发积累更大的兴趣。
曼哈顿算法:
H = 10*(abs(currentX-targetX) + abs(currentY-targetY))        //abs绝对值
 
对角线快捷
 
xDistance = abs(currentX-targetX)                                            //abs绝对值  
yDistance = abs(currentY-targetY)
if xDistance > yDistance
     H = 14*yDistance + 10*(xDistance-yDistance)
else
     H = 14*xDistance + 10*(yDistance-xDistance)
end if

 

 
Advertisements

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: