Lesson 1: What is an Algorithm?
In this Lesson, you will learn what an algorithm is and how using algorithms in VEXcode VR enables you to create VEXcode VR projects with more diverse behaviors. Algorithmic projects instruct the VR Robot to respond to its environment, which will be necessary to solve the Dynamic Castle Crasher Challenge.
- Identify that algorithms are made up of sequence, selection, and loops.
- Identify that algorithms are precise sequences of instructions, implemented using programming languages, for processes to be carried out by a VR Robot.
Algorithms are precise sequences of instructions, implemented using programming languages, like VEXcode VR, for processes to be carried out by a VR Robot.
The basic elements of an algorithm are sequence, selection, and iteration.
- Sequence - the order in which behaviors and commands are combined in a project in order to produce a desired result.
- Selection - is the use of conditional statements in a project. Conditional statements such as [If then], or [If then else] affect the project flow of a VEXcode VR project.
- Iteration - algorithms often use repetition to execute steps a certain number of times, or until a certain condition is met. This is also known as "looping." Iteration can change the project flow by repeating a behavior a specified number of times or until a condition is met.
This example project from the Unit 8 challenge is an example of an algorithm. It includes a combination of loops, sensor data, and commands put together in a sequence to solve the Disk Mover Challenge.
The project uses iteration or “loops” to repeat actions and check reported sensor values.
The way commands are sequenced and combined determines the behaviors of the VR Robot. This project also includes selection which determines the parts of the project that are run based on the sensor condition.