> For the complete documentation index, see [llms.txt](https://docs.revrobotics.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.revrobotics.com/rev-professional-development-technical-path/blocks-boot-camp/pseudocode.md).

# Planning with Pseudocode

Sometimes it can feel like the robot is just not doing what we want it to. We don't speak the same language after all, making it feel like something is lost in translation.&#x20;

<figure><img src="https://3023198990-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnKoHwxC0Q1NBpLowZUmu%2Fuploads%2Fjn19iGSuXxNs2ioLj6Hf%2Fimage.png?alt=media&amp;token=867b97d3-c294-4ed2-938a-87eae52fda7e" alt=""><figcaption><p>Robots and us don't speak the same language</p></figcaption></figure>

With practice we can better understand what we're programming the robot to ACTUALLY do vs. what we THINK we've asked the robot to do. Especially after growing more familiar with how the robot interprets certain movements and actions.&#x20;

## What is Pseudocode?&#x20;

A **pseudocode** represents a program, but is described using everyday familiar wording. It's a way to break things down in a more digestible way while thinking through what we want the program to do without getting lost in technical jargon.&#x20;

When working on a large project, creating a pseudocode during planning can help students think about what they expect the robot to do and what the end goal will be.&#x20;

<figure><img src="https://3023198990-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnKoHwxC0Q1NBpLowZUmu%2Fuploads%2FKve0rkS1PoIv7RhpI0RV%2Fimage.png?alt=media&amp;token=be0e3cdd-920d-43cc-ba0d-7879917f48d9" alt=""><figcaption><p>An example of a pseudocode alongside the Blocks code</p></figcaption></figure>

### When Writing Pseudocode:

Writing a pseudocode is like writing directions for how to make your favorite snack. The directions need to be clear, but simple so someone else can easily follow along.

* Use important keywords/statements (if/then or if/else, while the loop, assign the variable, etc)
* Think about the order of operations and logic
* Notate a clear structure of where a program starts and stops
* Keep it simple!

{% hint style="success" %}
When writing a pseudocode, students should still consider directions AND measurements. For example, "turn right 90 degrees" vs. just "turn right".&#x20;

If we're thinking like a robot, "turn right" may mean to turn forever to the right in a circle!
{% endhint %}

### Pseudocode Practice Activities:

The above provides key things to keep in mind when writing pseudocode, but there's no one right way to write one. How we thinking through a program changes per person and task!&#x20;

#### Pick a Task

The easiest way to practice writing pseudocode is to pick a simple task for the robot to complete and writing from there. Let's look at the field for the Unit 4 activity from the Intro to Robotics V2 curriculum as an example:&#x20;

<img src="https://3023198990-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnKoHwxC0Q1NBpLowZUmu%2Fuploads%2FqhJw2T0Zl88jsMsl977v%2Funknown.png?alt=media&amp;token=62aecdce-f1ed-49a9-8868-f8ad4f4cbde3" alt="Example field set up for Robot Lunch Rush" height="468" width="624">

Let's start simple. Maybe we want the robot to stop at the first bin on the left. How would it get there? Try writing a pseudocode before looking at the sample answer below!

<details>

<summary>Example Pseudocode</summary>

* Start Program
* Drive forward for 2 seconds
* Stop moving for 1 second
* Turn left for 1 second then stop
* Drive forward for 1 second
* Stop Program

</details>

For the rough draft of the pseudocode, the timings and movements do not need to be perfect. In fact it's likely it won't be perfect the first time.&#x20;

This is about building a framework to make adjustments from!&#x20;

Consider more challenging movements like:

* The robot drives to the far bin, then back to one of the side bins.
* The robot moves between two of the side bins.
* The robot stops at the first bin on the left then the upper bin on the right.

#### Paperless Programming

Have students partner up with one student being the "robot" and one being the "programmer". Next, choose a simple task, like the robot walking across the room and picking up an item, that the programmer will write a pseudocode for.

Once ready the student "robot" will follow the written directions!&#x20;

<details>

<summary>Example Pseudocode</summary>

* Start program
* Robot turn right 90 degrees
* Robot walk forward for 5 seconds
* Robot lift right arm for 1 second
* Robot close hand on book
* Robot lift right arm for 1 second
* Robot turn left 180 degrees
* Robot walk forward for 5 seconds
* Stop program

</details>

While completing this activity, student "robots" should do their best to follow the directions provided to the best of their abilities, however they should also be encouraged to be silly and have fun with it if there are key things missing, like units of measurement. Students will likely observe differences in what someone considers a "step" or even how they count seconds.

**Note:** They do not need to feel restricted by the limitations of Blocks or OnBot Java!&#x20;

After "testing" their program, students should swap roles and may repeat this activity for practice.
