深度优先迷宫生成类
来源:互联网 发布:java 创建自定义菜单 编辑:程序博客网 时间:2024/05/04 19:00
package maze.eng;
import java.util.Random;
public class mapBuilderChilderOne extends mapBuilderFarther
{
boolean set = true;
int xNum;
int yNum;
int count;
int xEnd;
int yEnd;
int keeper;
int longNum;
long time;
manage theManage;
public mapBuilderChilderOne()
{
xNum = 2;
yNum = 2;
count = 0;
xEnd = 2;
yEnd = 2;
keeper = 0;
}
public manage getMap(int myIn)
{
count = 0;
keeper = 0;
longNum = myIn;
set = true;
theManage = new manage(myIn);
time = System.currentTimeMillis();
while(set)
{
xNum = 2;
yNum = 2;
count = 0;
xEnd = 2;
yEnd = 2;
keeper = 0;
time++;
set = false;
theManage.renew();
Random rand = new Random(time);
building(rand, xNum, yNum, theManage);
}
theManage.setManage(xEnd, yEnd, '4');
theManage.setManage(xNum, yNum, '3');
theManage.setX(xNum);
theManage.setY(yNum);
return theManage;
}
private void building(Random rand, int x, int y, manage myIn)
{
keeper++;
if(count == 0 || count > longNum - 2)
{
myIn.setManage(x, y, '2');
int buiDateIntOne = rand.nextInt() % 4;
while(buiDateIntOne < 0)
{
buiDateIntOne = rand.nextInt() % 4;
}
int buiContIntOne = 0;
while(buiContIntOne < 4)
{
if(buiDateIntOne == 0)
{
if(myIn.judgeBuild(x - 1, y))
{
building(rand, x - 1, y, myIn);
}
buiContIntOne++;
buiDateIntOne++;
buiDateIntOne %= 4;
}
else if(buiDateIntOne == 1)
{
if(myIn.judgeBuild(x + 1, y))
{
building(rand, x + 1, y, myIn);
}
buiContIntOne++;
buiDateIntOne++;
buiDateIntOne %= 4;
}
else if(buiDateIntOne == 2)
{
if(myIn.judgeBuild(x, y - 1))
{
building(rand, x, y - 1, myIn);
}
buiContIntOne++;
buiDateIntOne++;
buiDateIntOne %= 4;
}
else if(buiDateIntOne == 3)
{
if(myIn.judgeBuild(x, y + 1))
{
building(rand, x, y + 1, myIn);
}
buiContIntOne++;
buiDateIntOne++;
buiDateIntOne %= 4;
}
}
if(count == 0)
{
xEnd = x;
yEnd = y;
}
}
if(keeper < longNum)
{
count = longNum;
set = true;
}
count++;
}
}
- 深度优先迷宫生成类
- 深度优先搜索生成迷宫
- 深度优先+回溯法生成随机迷宫
- 深度优先遍历之迷宫生成算法
- java随机生成迷宫(图的深度优先遍历)
- java随机生成迷宫(图的深度优先遍历)
- 深度优先算法生成迷宫——Python实现
- 基于广度优先算法迷宫生成类
- 迷宫代码:深度优先算法
- 深度优先和广度优先遍历迷宫
- 迷宫路径&广度优先求解&深度优先求解&迷宫游戏
- 利用深度优先搜索做的随机生成地图的迷宫小游戏
- 关于用深度优先算法生成迷宫与寻找路径的一些回忆
- 三大迷宫生成算法 (Maze generation algorithm) -- 深度优先,随机Prim,递归分割
- 生成迷宫的深度优先遍历算法的非递归实现
- 深度优先生成树
- 数据结构 深度优先 迷宫问题代码
- 深度优先——迷宫算法
- silverlight
- XMPP
- C# 里怎样得到当前执行的函数名,当前代码行,源代码文件名
- webwork中解决action跳转到action丢失参数的问题
- 跟学术不相称的道德水平
- 深度优先迷宫生成类
- Asp.net Title 标题闪烁的script
- 努力!
- 利用instr()函数防止SQL注入攻击
- 物流配送综合管理信息系统
- SQL注入攻击的原理及其防范措施
- SMDK2440A 5.0BSP之eboot流程(作者:wogoyixikexie@gliet)
- 基于广度优先算法迷宫生成类
- Oracle Develop OpenWorld 2008 印象