 # How do i make this script iterative

Hi below is the attcahed grasshopper/rhino file. I have created a grid of size 2150x2150. And i am creating a maze using the centroids of the grid.so my aim is to make the whole process iterative. that is as i change the angle of the grid.i should be able to change the maze angel as well. so as to get multiple iterations.And how do i decide upon the start point of the maze?exp2.3dm (190.8 KB) exp2.gh (46.2 KB)

this might be the start of a solution -it’s just a dirty prototype- with this slider you decide from which tile you want to start the walk

exp2_maybe.gh (55.3 KB)

edit: …and of course you can use mass addition to sum up all the vectors instead of looping them

exp3_maybe.gh (55.4 KB)

1 Like

Thanks a lot !!!
As i am a beginner to grasshopper i have certain doubts in the script that u had shared.Please find attached marked image of the step that i couldn’t follow.

Also i wanted to know the logic behind this maze?

given a starting point and a reference plane:

the directions of movement are determined by the plane on which the drawing is

length of a step = length of a single tile
the pattern moves:
2 steps up
2 steps left
4 steps down
4 steps right
…and so on, with length increment of +2 steps each two changes of direction

so first thing is to create a list of 4 unit vectors pointing the right directions, this list can be repeated “forever”

at this point we give the vectors the right final length by multiplying:
vectors * right amount of steps * step length
step increment is 2, 2, 4, 4, 6, 6, 8, 8… it’s a serie starting from 2, with increment +2 (2, 4, 6, 8…) where each element is repeated one additional time (duplicate data)

we can now move the initial point by the list of vectors we have generated
the problem is: we have a list of vector (movements) to be executed after each other, in that order
if we use that list “as it is” the point will be each time moved by each vector from its starting position
this is easily solved by using a mass addition component, because it also outputs the partial results of each sum

we then use that list of points to generate an open polyline

I initially didn’t recognise the second branch is just the first one rotated 180 degrees, so that simplifies even more the whole process

exp4_maybe.gh (53.0 KB)

of course the very same results can be achieved in very different ways… this is just one of the many 