add weird obfuscated code for fun
This commit is contained in:
@@ -770,6 +770,11 @@ public class LabyModel
|
||||
}
|
||||
|
||||
public boolean reverse(boolean grow)
|
||||
{
|
||||
return reversefast(grow);
|
||||
}
|
||||
|
||||
public boolean reversefast(boolean grow)
|
||||
{
|
||||
// use current moves as walls ... and rebuild new direction from it.
|
||||
|
||||
@@ -840,5 +845,73 @@ public class LabyModel
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean obfuscated_reverse(boolean grow)
|
||||
{
|
||||
// use current moves as walls ... and rebuild new direction from it.
|
||||
|
||||
int deltasize = grow ? 1 : -1;
|
||||
int newwidth = getWidth() + deltasize;
|
||||
int newheight = getHeight() + deltasize;
|
||||
int delta = grow ? 1 : 0;
|
||||
|
||||
if ( ( newwidth < 1) || (newheight < 1 ) )
|
||||
{
|
||||
System.err.println("Can't reverse, too small");
|
||||
return false;
|
||||
}
|
||||
short newt[][] = new short[newwidth][newheight];
|
||||
|
||||
short[][] rdul = {
|
||||
{ Brick.RIGHT, Brick.DOWN },
|
||||
{ Brick.UP, Brick.LEFT }};
|
||||
short[] allmoves = { LEFT,UP,RIGHT, DOWN };
|
||||
|
||||
for (int x = 0; x < getWidth() -1 ; x ++)
|
||||
{
|
||||
for (int y = 0; y < getHeight() -1 ; y ++)
|
||||
{
|
||||
short walls = 0;
|
||||
// invert moves to walls
|
||||
|
||||
// OBFUSCATED UNDEBUGGABLE VERSION
|
||||
for (int i = 0 ; i < 2; i ++)
|
||||
{
|
||||
for( int a=0 ; a < 2; a ++) {
|
||||
for (int c = 0; c < 2; c ++) {
|
||||
int d = a + c;
|
||||
int f = a * c;
|
||||
int b = d - 2 * f;
|
||||
int g = c * i;
|
||||
int e = c * b - g;
|
||||
if (((short) (t[x + a][y + b] >> FLAGLENGTH) & rdul[d - f - g ][i + f - g]) != 0) {
|
||||
walls |= rdul[1 - b + e][i + e];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// convert walls to moves, walls are actualy where there is no path : XOR to invert.
|
||||
short moves = (short) ((walls ^ ( Brick.RIGHT | Brick.LEFT | Brick.UP | Brick.DOWN )) << FLAGLENGTH);
|
||||
short finalmoves = 0;
|
||||
if ( moves == 0 )
|
||||
{
|
||||
finalmoves = 0;
|
||||
}
|
||||
else {
|
||||
for (short m : allmoves) {
|
||||
if ((moves & m) != 0) {
|
||||
finalmoves |= m;
|
||||
}
|
||||
}
|
||||
}
|
||||
newt[x+delta][y+delta] = finalmoves;
|
||||
}
|
||||
}
|
||||
width = newwidth;
|
||||
height = newheight;
|
||||
t = newt;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user