A*算法研究(含演示程序) |
| 作者:不详 来源:本站整理 发布时间:2005-11-24 16:45:54 |
|
begin_y); //System.out.println("0"); if(!isBalk(begin_x + 1,begin_y)){ addInOpenList(begin_x + 1,begin_y); setFather(begin_x + 1,begin_y,begin_x,begin_y); getGHF(begin_x + 1,begin_y); } //System.out.println("1"); if(!isBalk(begin_x - 1,begin_y)){ addInOpenList(begin_x - 1,begin_y); setFather(begin_x - 1,begin_y,begin_x,begin_y); getGHF(begin_x - 1,begin_y); } //System.out.println("2"); if(!isBalk(begin_x,begin_y + 1)){ addInOpenList(begin_x,begin_y + 1); setFather(begin_x,begin_y + 1,begin_x,begin_y); getGHF(begin_x,begin_y + 1); } //System.out.println("3"); if(!isBalk(begin_x,begin_y - 1)){ addInOpenList(begin_x,begin_y - 1); setFather(begin_x,begin_y - 1,begin_x,begin_y); getGHF(begin_x,begin_y - 1); } AAsterisk_t(); } private void AAsterisk_t() { int minIndex; int x, y; minIndex = theMinFInOpenList(); if(minIndex == -1){return;} x = openList[minIndex][0]; y = openList[minIndex][1]; addInCloseList(x,y); removeFromOpenList(x,y); if(!isBalk(x + 1,y)){ if(!isInCloseList(x + 1,y)){ if(isInOpenList(x + 1,y)){ if(mapInfo[y][x + 1][2] > getG(x + 1,y)+mapInfo[y][x + 1][5]){ setFather(x + 1,y,x,y); getGHF(x + 1,y); } } else{ addInOpenList(x + 1,y); setFather(x + 1,y,x,y); if(x + 1 == end_x&&y == end_y){ return; } getGHF(x + 1,y); } } } if(!isBalk(x - 1,y)){ if(!isInCloseList(x-1,y)){ if(isInOpenList(x-1,y)){ if(mapInfo[y][x-1][2] > getG(x-1,y)+mapInfo[y][x][5]){ setFather(x-1,y,x,y); getGHF(x-1,y); } } else{ addInOpenList(x-1,y); setFather(x-1,y,x,y); if(x - 1 == end_x&& y == end_y){ return; } getGHF(x-1,y); } } } if(!isBalk(x,y+1)){ if(!isInCloseList(x,y+1)){ if(isInOpenList(x,y+1)){ if(mapInfo[y+1][x][2] > getG(x,y+1) +mapInfo[y+1][x][5]){ setFather(x,y+1,x,y); getGHF(x,y+1); } } else{ addInOpenList(x,y+1); setFather(x,y+1,x,y); if(x == end_x&&y + 1 == end_y){ return; } getGHF(x,y+1); } } } if(!isBalk(x,y-1)){ if(!isInCloseList(x,y-1)){ if(isInOpenList(x,y-1)){ if(mapInfo[y-1][x][2] >getG(x,y-1)+mapInfo[y-1][x][5]){ setFather(x,y-1,x,y); getGHF(x,y-1); } } else{ addInOpenList(x,y-1); setFather(x,y-1,x,y); if(x == end_x&& y - 1== end_y){ return; } getGHF(x,y-1); } } } AAsterisk_t(); } private void showfather(int x, int y) { if(x == begin_x&&y == begin_y){System.out.println();return;} System.out.print("("+mapInfo[y][x][0]+","+mapInfo[y][x][1]+")"); int fx = mapInfo[y][x][0]; int fy = mapInfo[y][x][1]; gb.setColor(0x00ff0000); gb.fillArc(fx * cw, fy * ch, cw,ch, 0, 360); showfather(mapInfo[y][x][0],mapInfo[y][x][1]); } } 相关下载:点击下载 |
| [] [返回上一页] [打 印] |
|
文章评论 |
