If statements in array – #3 by Jimma – Beginners

Hi all,

First of all I am very inexperienced with processing and this is a first attempt to create a simple set of rules. My goal is to transfer between various states (A,B,C,D) and finally make the program terminate itself in the desired state. Now I’ve set up a few array’s that refer to a state that could either be 1 or 0.

I want to use if statements to make them progress further. So A (random 1 or 0) → A1 goes to state D1 and D1 goes to state A0 (example). Whenever I want to use the array to specify this, it referes to int not matching with boolean. I’m a bit lost, below my code.

int A1 = 1; //values for the states.
int A0 = 0;
int B1 = 1;
int B0 = 0;
int C1 = 1;
int C0 = 0;
int D1 = 1;
int D0 = 0;


int[] A = {A0, A1}; //array with the values A0 and A1
int[] B = {B0, B1}; //array with the values B0 and B1
int[] C = {C0, C1}; //array with the values C0 and C1
int[] D = {D0, D1}; //array with the values D0 and D1

void setup() {

int randomA = (int)random(A.length); // choose a random number from the A possibilities.

int randomB = (int)random(B.length); // choose a random number from the B possibilities.

int randomC = (int)random(C.length); // choose a random number from the C possibilities.

int randomD = (int)random(D.length); // choose a random number from the D possibilities.

void draw() {

if (A == 0) {
//fill (0, 90, 10);
//rect (25, 25, 25, 25);
} else if (A == 1) {
fill (80, 90, 10);
rect (25, 25, 25, 25);

Thanks for the help!

Read more here: Source link