Hello all,

This is my finite automaton rule 30. Some reason it is not printing out the correct pattern and I can not figure it out

public class CA_1D2S
{
public CA_1D2S() {
try {
jbInit();
} catch (Exception ex) {
ex.printStackTrace();
}
}

byte[][] DOUBLE_BUFFER;
int CurRow = 0;
int nxtRow = 1;
int RowSize = 181;
int cellStates = 2;
byte[] rules = {0,1,1,1,1,0,0,0};


public CA_1D2S(int RowSize)
{
DOUBLE_BUFFER = new byte[2][RowSize];
Initialize();
}

private void Initialize()
{
CurRow = 0; nxtRow = 1;

// Setting a variable to the length of my double buffer array
int len = DOUBLE_BUFFER[0].length;


for ( int i = 0; i < len; ++i)
{
// Initializing my DOUBlE_BUFFER to 0
DOUBLE_BUFFER[0][i] = 0;
DOUBLE_BUFFER[1][i] = 0;
}

// ** Middle bit ***
DOUBLE_BUFFER[CurRow][(len/2)] = 1;
}


public void reset()
{
Initialize();
}

public int CellCount()
{
return DOUBLE_BUFFER[0].length;
}

public byte[] GetCurRow()
{

return DOUBLE_BUFFER[CurRow].clone();

}

public int GetRowSize()
{
return RowSize;
}

public void TimeStep()
{

for(int i=1; i < DOUBLE_BUFFER[0].length-1; i++)
{
DOUBLE_BUFFER[nxtRow][i] = rules[ Map(i)];

//System.out.print(DOUBLE_BUFFER[CurRow][i]);

CurRow = 1 - CurRow; nxtRow = 1 - nxtRow;


}

System.out.print("\n");

}

private int Map(int Pos)
{
int n = 0;
for (int i = Pos-1; i <= Pos+1; ++i)
{
n *=2;
n += DOUBLE_BUFFER[CurRow][i] % 2;

}

return n;
}

private void jbInit() throws Exception {
}


}


class Test_CA
{
private int n = 50;

public Test_CA()
{
CA_1D2S ca = new CA_1D2S(n);
if (ca.GetRowSize()!= n)
{
System.out.print("ca.GetCutRow() !=50\n");
return;
}

}


}