I have been having trouble with this code and I haven't found the problem with the code. The maze generator just quits spawning in the wall objects after the first two, and I have already fixed multiple problems with the code. can anybody find a solution to this code?
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
public class MyWorld extends World
{
Actor[][] wallBoard;
int rand;
int x;
int y;
int z = 0;
boolean i = true;
boolean i1 = true;
boolean i2 = true;
boolean i3 = true;
boolean i4 = true;
public MyWorld()
{
super(1280, 720, 1, true);
setup();
}
public void setup()
{
wallBoard = new Actor[(getWidth() / 10) + 1][(getHeight() / 10) + 1];
x = Greenfoot.getRandomNumber(getWidth() / 10);
y = Greenfoot.getRandomNumber(getHeight() / 10);
rand = Greenfoot.getRandomNumber(3);
do
{
if (null == wallBoard[x][y])
{
wallBoard[x][y] = new wall();
addObject(wallBoard[x][y], (x * 10) + 5, (y * 10) + 5);
}
switch (rand)
{
case 0:
x--;
if (x < 0)
{
x = getWidth() / 10;
}
i2 = (
null == wallBoard[(x + 1 >= (getWidth() / 10) + 1) ? (0 + (x + 1)) : (x + 1)]
[(y + 2 >= (getHeight() / 10) + 1) ? (0 + (y + 2)) : (y + 2)] ||
null == wallBoard[(x - 1 <= -1) ? ((getWidth() / 10) + (x - 1)) : (x - 1)]
[(y + 2 >= (getHeight() / 10) + 1) ? (0 + (y + 2)) : (y + 2)]
);
i3 = (
null == wallBoard[(x - 2 <= -1) ? ((getWidth() / 10) + (x - 2)) : (x - 2)]
[(y + 1 >= (getHeight() / 10) + 1) ? (0 + (y + 1)) : (y + 1)] ||
null == wallBoard[(x - 2 <= -1) ? ((getWidth() / 10) + (x - 2)) : (x - 2)]
[(y - 1 <= -1) ? ((getHeight() / 10) + (y - 1)) : (y - 1)]
);
i4 = (
null == wallBoard[(x + 1 >= (getWidth() / 10) + 1) ? (0 + (x + 1)) : (x + 1)]
[(y - 2 <= -1) ? ((getHeight() / 10) + (y - 2)) : (y - 2)] ||
null == wallBoard[(x - 1 <= -1) ? ((getWidth() / 10) + (x - 1)) : (x - 1)]
[(y - 2 <= -1) ? ((getHeight() / 10) + (y - 2)) : (y - 2)]
);
if (i3 && i2 && i4)
{
rand = 1;
}
else if (i3 && i4)
{
rand = 3;
}
else if (i3 && i2)
{
rand = 2;
}
else if (i2 && Greenfoot.getRandomNumber(15) == 0)
{
rand = 2;
}
else if (i4 && Greenfoot.getRandomNumber(15) == 0)
{
rand = 3;
}
else if (i3)
{
switch (Greenfoot.getRandomNumber(1))
{
case 1:
rand = 3;
break;
case 0:
rand = 2;
break;
}
}
break;
case 1:
x++;
if (x > (getWidth() / 10))
{
x = 0;
}
i1 = (
null == wallBoard[(x + 2 >= (getWidth() / 10) + 1) ? (0 + (x + 2)) : (x + 2)]
[(y + 1 >= (getHeight() / 10) + 1) ? (0 + (y + 1)) : (y + 1)] ||
null == wallBoard[(x + 2 >= (getWidth() / 10) + 1) ? (0 + (x + 2)) : (x + 2)]
[(y - 1 <= -1) ? ((getWidth() / 10) + (y - 1)) : (y - 1)]
);
i2 = (
null == wallBoard[(x + 1 >= (getWidth() / 10) + 1) ? (0 + (x + 1)) : (x + 1)]
[(y + 2 >= (getHeight() / 10) + 1) ? (0 + (y + 2)) : (y + 2)] ||
null == wallBoard[(x - 1 <= -1) ? ((getWidth() / 10) + (x - 1)) : (x - 1)]
[(y + 2 >= (getHeight() / 10) + 1) ? (0 + (y + 2)) : (y + 2)]
);
i4 = (
null == wallBoard[(x + 1 >= (getWidth() / 10) + 1) ? (0 + (x + 1)) : (x + 1)]
[(y - 2 <= -1) ? ((getHeight() / 10) + (y - 2)) : (y - 2)] ||
null == wallBoard[(x - 1 <= -1) ? ((getWidth() / 10) + (x - 1)) : (x - 1)]
[(y - 2 <= -1) ? ((getHeight() / 10) + (y - 2)) : (y - 2)]
);
if (i1 && i2 && i4)
{
rand = 0;
}
else if (i1 && i4)
{
rand = 3;
}
else if (i1 && i2)
{
rand = 2;
}
else if (i2 && Greenfoot.getRandomNumber(15) == 0)
{
rand = 2;
}
else if (i4 && Greenfoot.getRandomNumber(15) == 0)
{
rand = 3;
}
else if (i1)
{
switch (Greenfoot.getRandomNumber(1))
{
case 1:
rand = 3;
break;
case 0:
rand = 2;
break;
}
}
break;
case 2:
y--;
if (y < 0)
{
y = getHeight() / 10;
}
i1 = (
null == wallBoard[(x + 2 >= (getWidth() / 10) + 1) ? (0 + (x + 2)) : (x + 2)]
[(y + 1 >= (getHeight() / 10) + 1) ? (0 + (y + 1)) : (y + 1)] ||
null == wallBoard[(x + 2 >= (getWidth() / 10) + 1) ? (0 + (x + 2)) : (x + 2)]
[(y - 1 <= -1) ? ((getWidth() / 10) + (y - 1)) : (y - 1)]
);
i3 = (
null == wallBoard[(x - 2 <= -1) ? ((getWidth() / 10) + (x - 2)) : (x - 2)]
[(y + 1 >= (getHeight() / 10) + 1) ? (0 + (y + 1)) : (y + 1)] ||
null == wallBoard[(x - 2 <= -1) ? ((getWidth() / 10) + (x - 2)) : (x - 2)]
[(y - 1 <= -1) ? ((getHeight() / 10) + (y - 1)) : (y - 1)]
);
i4 = (
null == wallBoard[(x + 1 >= (getWidth() / 10) + 1) ? (0 + (x + 1)) : (x + 1)]
[(y - 2 <= -1) ? ((getHeight() / 10) + (y - 2)) : (y - 2)] ||
null == wallBoard[(x - 1 <= -1) ? ((getWidth() / 10) + (x - 1)) : (x - 1)]
[(y - 2 <= -1) ? ((getHeight() / 10) + (y - 2)) : (y - 2)]
);
if (i4 && i1 && i3)
{
rand = 3;
}
else if (i4 && i1)
{
rand = 0;
}
else if (i4 && i3)
{
rand = 1;
}
else if (i1 && Greenfoot.getRandomNumber(15) == 0)
{
rand = 0;
}
else if (i3 && Greenfoot.getRandomNumber(15) == 0)
{
rand = 1;
}
else if (i4)
{
switch (Greenfoot.getRandomNumber(1))
{
case 1:
rand = 1;
break;
case 0:
rand = 0;
break;
}
}
break;
case 3:
y++;
if (y > (getHeight() / 10))
{
y = 0;
}
i1 = (
null == wallBoard[(x + 2 >= (getWidth() / 10) + 1) ? (0 + (x + 2)) : (x + 2)]
[(y + 1 >= (getHeight() / 10) + 1) ? (0 + (y + 1)) : (y + 1)] ||
null == wallBoard[(x + 2 >= (getWidth() / 10) + 1) ? (0 + (x + 2)) : (x + 2)]
[(y - 1 <= -1) ? ((getWidth() / 10) + (y - 1)) : (y - 1)]
);
i2 = (
null == wallBoard[(x + 1 >= (getWidth() / 10) + 1) ? (0 + (x + 1)) : (x + 1)]
[(y + 2 >= (getHeight() / 10) + 1) ? (0 + (y + 2)) : (y + 2)] ||
null == wallBoard[(x - 1 <= -1) ? ((getWidth() / 10) + (x - 1)) : (x - 1)]
[(y + 2 >= (getHeight() / 10) + 1) ? (0 + (y + 2)) : (y + 2)]
);
i3 = (
null == wallBoard[(x - 2 <= -1) ? ((getWidth() / 10) + (x - 2)) : (x - 2)]
[(y + 1 >= (getHeight() / 10) + 1) ? (0 + (y + 1)) : (y + 1)] ||
null == wallBoard[(x - 2 <= -1) ? ((getWidth() / 10) + (x - 2)) : (x - 2)]
[(y - 1 <= -1) ? ((getHeight() / 10) + (y - 1)) : (y - 1)]
);
if (i2 && i1 && i3)
{
rand = 2;
}
else if (i2 && i1)
{
rand = 0;
}
else if (i2 && i3)
{
rand = 1;
}
else if (i1 && Greenfoot.getRandomNumber(15) == 0)
{
rand = 0;
}
else if (i3 && Greenfoot.getRandomNumber(15) == 0)
{
rand = 1;
}
else if (i2)
{
switch (Greenfoot.getRandomNumber(1))
{
case 1:
rand = 1;
break;
case 0:
rand = 0;
break;
}
}
break;
}
}
while (
(
(
null == wallBoard[(x + 2 >= (getWidth() / 10) + 1) ? (0 + (x + 2)) : (x + 2)]
[(y + 1 >= (getHeight() / 10) + 1) ? (0 + (y + 1)) : (y + 1)] ||
null == wallBoard[(x + 2 >= (getWidth() / 10) + 1) ? (0 + (x + 2)) : (x + 2)]
[(y - 1 <= -1) ? ((getWidth() / 10) + (y - 1)) : (y - 1)]
) || x == (getWidth() / 10)
) ||
(
(
null == wallBoard[(x + 1 >= (getWidth() / 10) + 1) ? (0 + (x + 1)) : (x + 1)]
[(y + 2 >= (getHeight() / 10) + 1) ? (0 + (y + 2)) : (y + 2)] ||
null == wallBoard[(x - 1 <= -1) ? ((getWidth() / 10) + (x - 1)) : (x - 1)]
[(y + 2 >= (getHeight() / 10) + 1) ? (0 + (y + 2)) : (y + 2)]
) || x == (getHeight() / 10)
) ||
(
(
null == wallBoard[(x - 2 <= -1) ? ((getWidth() / 10) + (x - 2)) : (x - 2)]
[(y + 1 >= (getHeight() / 10) + 1) ? (0 + (y + 1)) : (y + 1)] ||
null == wallBoard[(x - 2 <= -1) ? ((getWidth() / 10) + (x - 2)) : (x - 2)]
[(y - 1 <= -1) ? ((getHeight() / 10) + (y - 1)) : (y - 1)]
) || x == 0
) ||
(
(
null == wallBoard[(x + 1 >= (getWidth() / 10) + 1) ? (0 + (x + 1)) : (x + 1)]
[(y - 2 <= -1) ? ((getHeight() / 10) + (y - 2)) : (y - 2)] ||
null == wallBoard[(x - 1 <= -1) ? ((getWidth() / 10) + (x - 1)) : (x - 1)]
[(y - 2 <= -1) ? ((getHeight() / 10) + (y - 2)) : (y - 2)]
) || y == 0
)
);
}
public void act ()
{
}
}
