1
$\begingroup$

I am trying to make an array of columns and rows like this:

rows and columns

but when I run my code

I get

incorrect rows and columns

why is this?

$\endgroup$
1
$\begingroup$

Not sure this question is really suited here, but well…

 x = 0
 y = 0
 for row in range(rows):
     x = x + scene.formationArrayColumnMargin
     for ag in range(int(agentsPerRow)):
         y = y + scene.formationArrayRowMargin

y must be reset to zero each time you run outer x loop, otherwise it keeps growing. Something like that:

x = 0
for row in range(rows):
    y = 0
    x = x + scene.formationArrayColumnMargin
    for ag in range(int(agentsPerRow)):
        y = y + scene.formationArrayRowMargin
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.