Okay, here's the outline. There are different ways to incorporate the pool, but as you need a lot of rotation, a random generator would be a good start.
You will need 6 random generators: One per pool and category (A/B). If I count correctly, you need 12 Images from each pool and each category (3+3+2+2+1+1). So, tell each random generator to draw 12 codes.
And you will need one seventh that decides which pages show which A/B-composition.
The, you'll need an IF filter to decide which pool to use, that is which pairs of random generators. Draw from these, and use valueList()
to write the 24 drawn codes into 3 arrays. Now you have one array drawn from pool 1, category A, and one from pool 1, category B. That is, you have 2x12 images drawn.
Now comes the tricky part. From your seventh generator you know the combinations, for example you might have drawn...
AABB
ABBB
ABBB
AAAB
AABB
AAAB
I would leave the rotation per trial to the selection question. So, let's leave this order for now, and imagine to write all images one after the other, that is:
AABB ABBB ABBB...
Okay, now you need to count which image to use for which position. We start with A0 for the first A and B0 for the first B and count up:
A0 A1 B0 B1 - A2 B2 B3 B4 - A3 B5 B6 B7 - ...
As soon as you have this information, you're ready to go. Now you know that on page 1, you have to use the array A[0], A[0], B[0] and B[1] for the selection to display. Unnecessary to say that you should use a loopPage() to go through the 6 selections.
Huh, not easy, but you opted for some complex design, this is how you put it down in code. And don't dare and as ChatGPT how to do it in PHP, it will only mislead you. Just start with the first step, see how far you come, and tell when you're stuck.