package maze.eng;
import java.util.ArrayList;
import java.util.Random;
public class mapBuilderChilderTwo extends mapBuilderFarther
{
boolean set = true;
int xNum;
int yNum;
int count;
int xEnd;
int yEnd;
int keeper;
int longNum;
long time;
ArrayList myListToKeepMid;
ArrayList myListToKeepEnd;
manage theManage;
public mapBuilderChilderTwo()
{
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;
myListToKeepMid = new ArrayList();
myListToKeepEnd = new ArrayList();
theManage = new manage(myIn);
time = System.currentTimeMillis();
Random rand = new Random(time);
theManage.setManage(xNum, yNum, '2');
listType temp = new listType(2, 2);
myListToKeepMid.add(temp);
while(!myListToKeepMid.isEmpty())
{
boolean contEnd = true;
int buiDateIntOne = rand.nextInt() % myListToKeepMid.size();
while(buiDateIntOne < 0)
{
buiDateIntOne = rand.nextInt() % myListToKeepMid.size();
}
listType tempKeeper = (listType)myListToKeepMid.get(buiDateIntOne);
if(theManage.judgeBuild(tempKeeper.getX() - 1, tempKeeper.getY()))
{
theManage.setManage(tempKeeper.getX() - 1, tempKeeper.getY(), '2');
listType tempUpOne =
new listType(tempKeeper.getX() - 1, tempKeeper.getY());
myListToKeepMid.add(tempUpOne);
contEnd = false;
}
if(theManage.judgeBuild(tempKeeper.getX() + 1, tempKeeper.getY()))
{
theManage.setManage(tempKeeper.getX() + 1, tempKeeper.getY(), '2');
listType tempDoOne =
new listType(tempKeeper.getX() + 1, tempKeeper.getY());
myListToKeepMid.add(tempDoOne);
contEnd = false;
}
if(theManage.judgeBuild(tempKeeper.getX(), tempKeeper.getY() - 1))
{
theManage.setManage(tempKeeper.getX(), tempKeeper.getY() - 1, '2');
listType tempLeOne =
new listType(tempKeeper.getX(), tempKeeper.getY() - 1);
myListToKeepMid.add(tempLeOne);
contEnd = false;
}
if(theManage.judgeBuild(tempKeeper.getX(), tempKeeper.getY() + 1))
{
theManage.setManage(tempKeeper.getX(), tempKeeper.getY() + 1, '2');
listType tempReOne =
new listType(tempKeeper.getX(), tempKeeper.getY() + 1);
myListToKeepMid.add(tempReOne);
contEnd = false;
}
if(contEnd == true)
{
myListToKeepEnd.add(tempKeeper);
}
myListToKeepMid.remove(buiDateIntOne);
}
int length = 0;
for(int i = 0; i < myListToKeepEnd.size(); i++)
{
listType keepLength = (listType)myListToKeepEnd.get(i);
if(keepLength.getX() + keepLength.getY() > length)
{
xEnd = keepLength.getX();
yEnd = keepLength.getY();
length = keepLength.getX() + keepLength.getY();
}
}
theManage.setManage(xEnd, yEnd, '4');
theManage.setManage(xNum, yNum, '3');
theManage.setX(xNum);
theManage.setY(yNum);
return theManage;
}
}