DAY 6: FUNCTIONS AND KAREL
<Using a virtual environment called ‘Reeborg’s world’ that has built in functions to create own set of instructions so the robot can navigate out of a maze. >
<Built in functions >
<TASK: Reeborg has entered a hurdles race. Make him run the course, following the path shown. >
<CODE AND OUTPUT >
<TASK: Reeborg has entered a hurdle race. Make him run the course, following the path shown.
The position and number of hurdles changes each time this world is reloaded. >
<CODE AND OUTPUT >
<TASK: Reeborg has entered a hurdle race, but he does not know in advance how long the race is. Make him run the course, following a path similar to the one shown, but stopping at the only flag that will be shown after the race has started. >
<CODE AND OUTPUT >
<TASK: Reeborg has entered a hurdle race. Make him run the course, following the path shown. The position, the height and the number of hurdles changes each time this world is reloaded. >
<CODE AND OUTPUT >
<TASK: Lost in a maze
Reeborg was exploring a dark maze and the battery in its flashlight ran out.
Write a program using an if/elif/else
statement so Reeborg can find the exit. The secret is to have Reeborg follow along the right edge of the maze, turning right if it can, going straight ahead if it can’t turn right, or turning left as a last resort. >
<CODE AND OUTPUT >
<Test World 1: Reeborg’s starting position is (3, 4) and has not walls around it, facing south>
<Test World 2: Reeborg’s starting position is (3, 4) and has not walls around it, facing north>
<Test World 3: Reeborg’s starting position is (3, 4) and has not walls around it, facing west>