reset password
Author Message
Anonymous
Posts: 166
Posted 20:29 Jan 07, 2014 |

For the robot exercise there are three possible instructions. Is it okay for the robot to crash or touch the wall if it moves foward by one unit because what if it reaches a point where four paths are possible when there are no walls next to it? If at the start the robot faces nothing and goes right until it reaches a wall, won't it be facing a loop when it reach that space where there are four paths and no walls adjacent to it?

rabbott
Posts: 1649
Posted 20:43 Jan 07, 2014 |

Good question!  You may assume that the robot enters the maze with it's right side to a wall as in this image. In this example, the robot enters at the upper left corner. It's right side is against a wall. It follows the right-hand-rule (the grey line) until it exits at the bottom right.

 



 

Last edited by rabbott at 20:44 Jan 07, 2014.
Eric Liao
Posts: 158
Posted 20:44 Jan 07, 2014 |

The right-hand rule tells you how to escape from a maze: Always have the right hand next to a wall, and eventually you will find an exit.

Right-hand rule does not mean that you need to turn right all the time to find a wall. But, when you find a wall, you simply keep the wall at your right hand side. For example, you may just keep moving forward until you find a wall. Then you turn left and move one step and check if your right hand side is still a wall or not.

Another way to think about it, in a real life example, keep your right hand on the wall and move around your room to see how right hand rule works in real life. And think about why it works. Or you may just draw a simple grid maze and put a robot inside. Followed by the right hand rule, you should be able to find the way out regardless of where robot is. In other word, try to find an example and see how right hand rule actually works first. Then, work on the algorithm after understanding the rule.

---

Since Dr. Abbott provided the image, follow by that image instead!

Last edited by Eric Liao at 20:45 Jan 07, 2014.
Anonymous
Posts: 166
Posted 21:07 Jan 07, 2014 |

How is it that we could write pseudocode that involves the robot sensing a wall to the right, for example, when the homework description said that the robot can only see what is directly in front of it? That's the way I wrote my pseudocode, considering reactions to events directly in front.

Eric Liao
Posts: 158
Posted 21:12 Jan 07, 2014 |

Yes, the robot cannot sense what is on the right hand side directly. However, you can turn right and sense whether it is a wall or not then left turn back. This is also the same as sensing whether the right hand side is a wall or not, just more steps.

Most of time, programming is just simplifying something into small simple steps that computer can do.

Anonymous
Posts: 166
Posted 21:14 Jan 07, 2014 |

Ok thank you

Eric Liao wrote:

Yes, the robot cannot sense what is on the right hand side directly. However, you can turn right and sense whether it is a wall or not then left turn back. This is also the same as sensing whether the right hand side is a wall or not, just more steps.

Most of time, programming is just simplifying something into small simple steps that computer can do.