Computer Science Level 1 - Blocks

Unit 9 - Developing Algorithms

# Lesson 4: Dynamic Castle Crasher Challenge

In the Dynamic Castle Crasher Challenge, the VR Robot must now knock ALL pieces off of each iteration of the Dynamic Castle Crasher Playground, in the quickest way possible!

## Learning Outcome

• Apply logic of repeated decisions with multiple sensors to solve the Dynamic Castle Crasher Challenge.

## Putting It All Together

Algorithms enable a user to create more diverse and efficient projects. Algorithms are precise sequences of instructions that can use selection and iteration to instruct the VR Robot to use information from its environment to execute behaviors.

Algorithms use loops to continually check sensor values, and repeat behaviors. Nesting conditional statements inside loops such as [Forever] or [Repeat until] blocks will instruct the VR Robot to continually check those conditions.

Selection is employed by using conditional statements such as [If then else] or [Repeat until] blocks to instruct the VR Robot to execute certain behaviors, depending on reported conditions, such as sensor values.

Using sensors with loops and selection enables the VR Robot to interact with a changing environment, such as the Dynamic Castle Crasher Playground.

## Dynamic Castle Crasher Challenge

In this challenge, create a project where the VR Robot uses an algorithm to knock all of the building pieces off of the Dynamic Castle Crasher Playground, in the shortest amount of time possible.

Solving the Dynamic Castle Crasher Challenge requires the use of a timer. You can use a stopwatch, a phone, or you can even use the timer on the VR Robot.

You can use the monitor feature in VEXcode VR, and select the (Timer value) block to be monitored. Every time the project is run, the monitor resets.

For more information on using the Monitor Console, view the Variable and Sensing Values Monitoring - Tutorials - VR Blocks article.

Follow these steps to complete the challenge:

• Create a new project or load a project from previous Lessons in this Unit.
• Rename the project Unit9Challenge.
• Launch the Playground window.
• Load the Dynamic Castle Crasher Playground.
• Add the blocks necessary to drive the VR Robot to push all of the building pieces off of the Dynamic Castle Crasher Playground in the shortest amount of time. The VR Robot should not fall off of the Playground.
• Start the project to test if it works. The algorithm should work regardless of the layout of the Playground.
• Document the time it took to complete the challenge on a piece of paper, on your device, or by monitoring the timer in VEXcode VR.
• Continue to revise and run the project until the VR Robot successfully completes the Dynamic Castle Crasher Challenge in the shortest time.
• Save the project once the VR Robot successfully knocks all of the building pieces off of the Dynamic Castle Crasher Playground in record time.

Congratulations! You have successfully completed the Dynamic Castle Crasher Challenge!