Growing Structure, Iteration/LoopWhile/ListMap

Hello everyone,
im trying to create a self growing 2d structure based off rectangles, later replaced by more complicated floors.The goal is to get a variable number of rectangles that are connected to each other. I started with a grid and placed a rectangle. Then Dynamo picks a random corner and a random angle from this rectangle and creates another one with this information. I copied this 20 times and it works, but i want to be more flexible so that i can change the numbers with a slider and dynamo automatically creates the rectangles. Therefore i dealt with LoopWhile, Custom Nodes, DesignScript and now im back to List.Map. Im pretty much a beginner and using Dynamo only since 3 Months. I cant get behind the problems that occur, whether its functions not working in the Loop or the LoopWhile crashing. There are too many Files where i tried it, so im uploading the recent three. I looked up other examples and tried to use them for this, but i guess im not 100% understanding it and therefore can´t find the solution by myself. Maybe there is a way easier solution to this. Nevertheless im linking them here (also the recent ones):

Well i cant upload something, cause im too new. Then i´ll try to write it down:
Basic process:
Rectangle.ByWidthLength - Polygon Corners - List.Flatten - List.Shuffle - List.First.Item
Code Block with angles - List.Flatten - List.Shuffle - List.First.Item → Create Geometry!

Then i tried to combine it with this code from the example above:

def move_cubes_shift(cubes:var[]){
return = [Imperative]{
dist = 0.1..1..#Count(cubes);
for (i in GetKeys(cubes) )
{
    old = List.TakeItems(cubes,i+1);
    to_move = List.DropItems(cubes,i+1);
    moved = {};
    for (c in to_move)
    {
        c1 = c.Translate(Vector.XAxis(), dist[i]);
        moved = List.AddItemToEnd(c1, moved);
    }
    cubes = Flatten({old, moved});
}
return = cubes;
}};

Im grateful for every help i can get. Thanks in advance!
DanielArch

Still not getting behind. Probably gonna learn to design skript for this.