|
p; this.m_openList[p_index - 1] = this.m_openList[father - 1]; this.m_openList[father - 1] = change; p_index = father; } else { break; } } } /** 将(取出开启列表中路径评分最低的节点后从队尾移到最前的)节点向后移动 */ private function backNote() : void { //尾部的节点被移到最前面 var checkIndex : int = 1; var tmp : int; var change : int; while(true) { tmp = checkIndex; //如果有子节点 if (2 * tmp <= this.m_openCount) { //如果子节点的F值更小 if(this.getScore(checkIndex) > this.getScore(2 * tmp)) { //记节点的新位置为子节点位置 checkIndex = 2 * tmp; } //如果有两个子节点 if (2 * tmp + 1 <= this.m_openCount) { //如果第二个子节点F值更小 if(this.getScore(checkIndex) > this.getScore(2 * tmp + 1)) { //更新节点新位置为第二个子节点位置 checkIndex = 2 * tmp + 1; } } } //如果节点位置没有更新结束排序 if (tmp == checkIndex) { break; } //反之和新位置交换,继续和新位置的子节点比较F值 else { change = this.m_openList[tmp - 1]; this.m_openList[tmp - 1] = this.m_openList[checkIndex - 1]; this.m_openList[checkIndex - 1] = change; } } }
其中 getScore() 方法:
/** * 获取某节点的路径评分F值 * @param p_index 节点在开启列表中的索引(从1开始) */ private function getScore(p_index : int) : int { //开启列表索引从1开始,ID从0开始,数组索引从0开始 return this.m_pathScoreList[this.m_openList[p_index - 1]]; }
进入织梦论坛讨论: http://www.17zm.net/forum/
上一页 [1] [2] [3] [4] |
| 教程录入:jerome 责任编辑:jerome |
上一篇教程: Apollo是危险的吗?
下一篇教程: 浅谈flash web的结构 |
| 【字体:小 大】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口】 |