Introduction
Hi! My name is HotRider. We will find hidden treasure on the map by playing the game Hot and Cold. Treasure is hidden on some of the tiles. My sensor values show how “hot” the surrounding tiles are. Help me reach the treasure by moving in the right direction.
Conditional Expressions
In this lesson, we will learn to use conditional expressions in robotics coding. We need to use conditional statements to let the robot decide what action it will take based on whether a statement is true or false. For example, if it is true that the tile in front of us is ‘hotter’, then we may decide to move forward. If it is true that the tile to the right is ‘hotter’, then we we can turn right and move forward. A ‘hotter’ tile means the tile has a number bigger than the number we are currently on.
Getting Started
- Start the simulation and open the simulation screen.
- You will see the number 2 on the tile in front of the robot, as shown in the image below. The robot is on top of a tile with number 1. Since 2 is higher than 1, this tells the robot that moving forward will take us from 1 to 2. Moving to higher numbers means we are getting closer to the treasure.
- The walls have been given a value of -1000. We can read this with our sensors but we do not show wall values to avoid clutter.
- After the robot moves you will be able to see the sensor values of the new position.