Lesson 4
Repeated Practice Makes Perfect
Chapter 7: Enhancing your robot
Moving your robot further
Ok, enough of solving mathematical problems.
I think we have neglected your poor robot project. Let us now try to improve your robot with all the awesome new problem solving skills you have just gained! 💪🤖 💪🤖
To recap, so far you have a robot that is placed at a random position in a grid, and facing a random direction. It then tries to move one step forward (if possible) in the direction it is facing. A good baby step.
Now, let us get your robot to walk more than just taking one step. Let’s get it to automatically move all the way to the edge of the grid.
So, if your robot is at (6,5) and facing South, it should move one step at a time from (7,5), then (8,5), then (9,5), then stop.
The following is an example run
What is the name of the robot? Terminator
Hello. My name is Terminator. My ID is 1000.
I am currently at (3, 6), facing East.
Moving one step forward.
I am currently at (3, 7), facing East.
Moving one step forward.
I am currently at (3, 8), facing East.
Moving one step forward.
I am currently at (3, 9), facing East.
I have a wall in front of me!
And another sample run when the robot is already at a boundary:
What is the name of the robot? Terminator
Hello. My name is Terminator. My ID is 1000.
I am currently at (0, 7), facing North.
I have a wall in front of me!
Remember to commit your code when you are done! Here is a reminder:
user@MACHINE:~/robot$ git add -u
user@MACHINE:~/robot$ git commit -m "Improved robot in main.py so that it automatically moves forward in the same initial direction until it hits a wall."
user@MACHINE:~/robot$ git status