I made the program! It will generate n
options for a tower. Every tower is tall random(min,max)
. It will generate every possibility. For now, every tower’s floor are just numbers. (tower with 3 floor has numbers: 0,1,2, one with 5 floors has numbers: 0,1,2,3,4 and so on). Now just plug in the words!
this is the principle behind its workings:
Code
ArrayList<Integer> sizes = new ArrayList<Integer>();
int n = 5, min = 1, max = 5, path[] = new int[n];
boolean end = false;
void setup() {
size(600, 600);
for (int i = 0; i < n; i++) sizes.add((int)random(min, max));
printArray(sizes);
printArray(path);
}
void draw() {
takePath(path);
for (int i = 0; i < n; i++) {
print(path[i]);
}
println();
if (end) noLoop();
}
void takePath(int pPath[]) {
pPath[n-1]++;
for (int i = n-1; i >= 0; i--) {
if (pPath[i] >= sizes.get(i)) {
pPath[i] = 0;
if (i > 0) {
pPath[i-1]++;
} else {
end = true;
}
}
}
path = pPath;
}