Perplexity Boolean array

Hello everyone!
I would like to ask for a hand: with this code that I wrote required uscrimi you must “true or false” values based on the randomNum values that I have assigned; instead I get only “false” values.
Also I should when i = 0 assign the container value [i] ie container [0] which then becomes 1 then container [1] etc.
I don’t understand what is missing :frowning:

If someone dares me a tip I would be grateful!
Thank you

Marika

float randomNum;
boolean[] contenitore = new boolean [5];

void setup() {
  size(400, 400);
  background(127);
  frameRate(1);
  println();
}

void draw() {
  randomNum = random(100);

  for (int i = 0; i < i; i = 1) {
    randomNum = 100;
    if (randomNum < 50) {
      contenitore [i] = true;
    } else {
      contenitore[i] = false;
      i = 1;
    }
    randomNum = 80;
    if (randomNum < 50) {
      contenitore [i] = true;
    } else {
      contenitore[i] = false;
      i = 2;
    }
    randomNum = 60;
    if (randomNum < 50) {
      contenitore [i] = true;
    } else {
      contenitore[i] = false;
      i = 3;
    }
    randomNum = 40;
    if (randomNum < 50) {
      contenitore [i] = true;
    } else {
      contenitore[i] = false;
      i = 4;
    }
    randomNum = 20;
    if (randomNum < 50) {
      contenitore [i] = true;
    } else {
      contenitore[i] = false;
      i = 5;
    }
  }

  println(contenitore);
}

1 Like

I just change this for me it’s enough like that

void draw() {
    for (int i = 0; i <contenitore.length; i++) {
        randomNum = random(100);
        if (randomNum < 50) contenitore [i] = true;
        else contenitore[i] = false;
    }
    println(contenitore);
}
2 Likes

Thanks a lot for your help, very kind! :smiling_face_with_three_hearts: