C#開發(fā)的OpenRA游戲之基地工程車移動8
根據前面A*算法分析,我們知道下面這段代碼,就是采用對角線距離來計算的,因為游戲里允許對角線移動,采用計算公式如下:
function heuristic(node) =
??? dx = abs(node.x - goal.x)
??? dy = abs(node.y - goal.y)
??? return D * (dx + dy) + (D2 - 2 * D) * min(dx, dy)
變成游戲里的代碼:文章來源:http://www.zghlxwxcb.cn/news/detail-466629.html
?? ??? ?/// <summary>
?? ??? ?/// Default: Diagonal distance heuristic. More information:
?? ??? ?/// http://theory.stanford.edu/~amitp/GameProgramming/Heuristics.html
?? ??? ?/// </summary>
?? ??? ?/// <returns>A delegate that calculates the estimatio文章來源地址http://www.zghlxwxcb.cn/news/detail-466629.html
到了這里,關于C#開發(fā)的OpenRA游戲之基地工程車移動8的文章就介紹完了。如果您還想了解更多內容,請在右上角搜索TOY模板網以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網!