Step 2

Analyzing the Maze Components

Now let’s start creating the initial parts of our program.

Before we do this, take a look at the maze. What are some things our robot will need to do?

There are three main things. It needs to perform some sort of an action for each of the three colored disks.

It also needs to be constantly checking to see if it needs to peform these actions.

With all of this known, we can create the beginning structure of our program.

Initial Program Structure

We need to something to help us constantly check if we are looking for a disk, this sounds like a great place to use a loop!

We also need to check if our robots front eye detects any of the three colors, let’s use some if statements to check for those conditions.

For the sake of efficiency, we should only be checking for one of the colors if we know we’re near an object, otherwise we shouldn’t have to worry about any checking. Let’s use an if/else statement for that.

What we’ve done is laid out all the things we want our program to account for, we haven’t figured out exactly what all these sections will do yet, but having it all laid out for us can be a great help to our thought process.

See if you can figure out the rest of the code from here! Move on when you are either ready to check your work or get stuck.