Helping the Computer
Do you remember a few steps back, where I told you to write down some of your favourite values for increase and degrees, the ones that gave the best-looking patterns? If you didn’t do this, don’t worry: you can just watch the random program run for a while now and write down the combinations that give great results.
You’re going to teach Scratch those combinations of values, so it can use them to make nothing but awesome pictures!
To do this, you’ll need a list. You’ll find lists with the variables in the Variables section. Just like you did with your variables, you’ll need to create your list first!
Click Make a List, and enter Degrees List as the name.

Your list, which is empty at the moment, will appear on the Stage, and you’ll see a bunch of blocks for it in Variables.

Make another list called Increase List
Now, by clicking on the little plus sign (+) at the bottom of the lists, add in the first pair of values of increase and degrees you liked, each value into the right list. Do this again to add the second pair of values. This will be enough for now — you’ll add the rest of the value pairs you like later!

Make sure that the degrees value and the increase value that worked well together are at the same position in the Degrees List and the Increase List. They need to be there so your program can match them up again using their position!
Now you have the lists, you just need to get your code to read them and loop over them! To do this, you’re going to use a new variable to act as a counter, some incrementing, and an if then Control block.
What does incrementing mean?
To increment something means to add something to it.
You will use a variable to act as a counter to keep track of what position you’re at in your lists. To move through the lists, you’ll keep incrementing the counter by 1 (so, adding 1 to it) until you get to the end of the list.
Create a new variable called counter, and update your code to look like this:
Notice the new blocks that:
- Set
counterto0, outside all the loops. - Check if the number stored in
counteris the length of the list, and if so, setcounterto0. This means that this variable will always be the number of a position in the lists, and won’t get any bigger than that. - Add
1tocounter. - Pick the item from
Increase Listthat is at the position described bycounter, and put it in theincreasevariable. Do the same for theDegrees Listanddegreesvariable.
How does the code work?
This is what happens when you run your program:
- Set
counterto0. - Start the
foreverloop. - Check if
counter(0) is the same as the length ofIncrease List(2). It isn’t. - Change
counterby1. Nowcounter=1. - Set
stepsto0. - Get the item at the position named by
counter(1) in theIncrease List, and put it inincrease. - Get the item at the position named by
counter(1) in theDegrees List, and put it indegrees. - Do all the stuff related to drawing the patterns.
- Restart the
foreverloop: - Check if
counter(1) is the same as the length ofIncrease List(2). It isn’t. - Change
counterby1. Nowcounter=2. - Set
stepsto0. - Get the item at the position named by
counter(2) in theIncrease List, and put it inincrease. - Get the item at the position named by
counter(2) in theDegrees List, and put it indegrees. - Do all the stuff related to drawing the patterns.
- Restart the
foreverloop: - Check if
counter(2) is the same as the length of theIncrease List(2). It is! - Set
counterto0. - Continue from step 4 of this list, in a never-ending loop!
Once you’re happy with the code, go ahead and add the rest of the pairs of values you noted down to the Degrees List and the Increase List.
That’s it! Sit back and watch your program keep drawing lovely patterns in a never-ending loop! If you want to add more patterns, you can: just add more pairs of numbers to the two lists and restart the program.