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 Answer 1

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$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .