bool32 active
bool32.rising trigger
bool32.rising reset
frac32.positive wave
bool32 bit0
bool32 bit1
bool32 bit2
bool32 bit3
bool32 bit4
bool32 bit5
bool32 bit6
bool32 bit7
combo automata bit width
combo init method mode
spinner rule default 30
bool32 bit0
bool32 bit1
bool32 bit2
bool32 bit3
bool32 bit4
bool32 bit5
bool32 bit6
bool32 bit7
int tgate, rgate, sum;
int out[attr_width];
int b0, b1, b2, b3, b4, b5, b6, b7;
int rules[8];
int state[attr_width];
int newstate[attr_width];
int i, k;
tgate = 0;
rgate = 0;
sum = 0;
i = 0;
k = 0;
rules[0] = (attr_rule & 1) ? 1 : 0;
rules[1] = (attr_rule & 2) ? 1 : 0;
rules[2] = (attr_rule & 4) ? 1 : 0;
rules[3] = (attr_rule & 8) ? 1 : 0;
rules[4] = (attr_rule & 16) ? 1 : 0;
rules[5] = (attr_rule & 32) ? 1 : 0;
rules[6] = (attr_rule & 64) ? 1 : 0;
rules[7] = (attr_rule & 128) ? 1 : 0;
if (attr_mode == 1) {
for (i = 0; i < attr_width; i++)
state[i] = GenerateRandomNumber() % 3;
for (i = 0; i < attr_width; i++)
newstate[i] = 0;
}
else {
for (i = 0; i < attr_width; i++)
state[i] = 0;
for (i = 0; i < attr_width; i++)
newstate[i] = 0;
state[attr_width / 2] = 1;
}
if (inlet_active > 0) {
if ((inlet_trig > 0) && !tgate) {
for (i = 0; i < attr_width; i++) {
k = 4 * state[(i - 1 + attr_width) % attr_width] + 2 * state[i] +
state[(i + 1) % attr_width];
newstate[i] = rules[k];
}
for (i = 0; i < attr_width; i++) {
state[i] = newstate[i];
if (state[i] == 1)
out[i] = 1;
else
out[i] = 0;
}
tgate = 1;
}
else if (!(inlet_trig > 0))
tgate = 0;
outlet_bit0 = out[0];
outlet_bit1 = out[1];
outlet_bit2 = out[2];
outlet_bit3 = out[3];
outlet_bit4 = out[4];
outlet_bit5 = out[5];
outlet_bit6 = out[6];
outlet_bit7 = out[7];
disp_bit0 = out[0];
disp_bit1 = out[1];
disp_bit2 = out[2];
disp_bit3 = out[3];
disp_bit4 = out[4];
disp_bit5 = out[5];
disp_bit6 = out[6];
disp_bit7 = out[7];
if (out[0] == 1)
b0 = 1;
else
b0 = 0;
if (out[1] == 1)
b1 = 2;
else
b1 = 0;
if (out[2] == 1)
b2 = 4;
else
b2 = 0;
if (out[3] == 1)
b3 = 8;
else
b3 = 0;
if (out[4] == 1)
b4 = 16;
else
b4 = 0;
if (out[5] == 1)
b5 = 32;
else
b5 = 0;
if (out[6] == 1)
b6 = 64;
else
b6 = 0;
if (out[7] == 1)
b7 = 128;
else
b7 = 0;
sum = (b0 + b1 + b2 + b3 + b4 + b5 + b6 + b7) * (1 << 19);
outlet_wave = sum;
}
else {
outlet_wave = 0;
outlet_bit0 = 0;
outlet_bit1 = 0;
outlet_bit2 = 0;
outlet_bit3 = 0;
outlet_bit4 = 0;
outlet_bit5 = 0;
outlet_bit6 = 0;
outlet_bit7 = 0;
}
if ((inlet_rst > 0) && !rgate) {
if (attr_mode == 1) {
for (i = 0; i < attr_width; i++)
state[i] = GenerateRandomNumber() % 3;
for (i = 0; i < attr_width; i++)
newstate[i] = 0;
}
else {
for (i = 0; i < attr_width; i++)
state[i] = 0;
for (i = 0; i < attr_width; i++)
newstate[i] = 0;
state[attr_width / 2] = 1;
}
i = 0;
k = 0;
rgate = 1;
}
else if (!(inlet_rst > 0))
rgate = 0;