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 infinite while loops or while loops with a not condition will instruct the VR Robot to continually check those conditions.
def main():
while True:
if distance.found_object():
# Knock over the building found using the Distance Sensor
drivetrain.drive(FORWARD)
else:
# Turn to find a building using the Distance Sensor
drivetrain.turn(RIGHT)
wait(5, MSEC)
Selection is employed by using conditional statements such as if else 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 the castle 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 the timer in the Playground Window.
Follow these steps to complete the challenge:
- Create a new project or load a project from previous Lessons in this Unit. If creating a new project, select the Dynamic Castle Crasher Playground when prompted.
- Rename the project Unit9Challenge.
- Open the Playground window if it is not already open. Be sure the Dynamic Castle Crasher Playground opens.
- Add the commands 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.
- 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!