WAP之家:为您提供最全最新的WAP技术,CP.SP.3G等行业资讯。 WAP之家交流论坛全新开放 点击进入>>
WAP资讯 | 3G动态 | SP动态 | 运营商动态 | 内容商动态 | 制造商动态 | 论坛讨论>> 每次自动访问
WAP技术 | WAP源码 | 手机编程 | 手机源码 | 无线技术 | J2ME技术 | 手机软件 添加到收藏夹
IVR技术 | SP资料 | SMS MMS技术 | 商业方案 | IVR下载 | 书籍教程 | 工具软件 语言:繁體中文

WAP之家技术文章J2ME技术程序开发A*算法研究(含演示程序)

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]);
}
}

相关下载:点击下载

上一页  [1] [2] [3] 

[] [返回上一页] [打 印]
文章评论

用户名: 查看更多评论

分 值:100分 85分 70分 55分 40分 25分 10分 0分

内 容:

         (注“”为必填内容。) 验证码: 验证码,看不清楚?请点击刷新验证码