Lab 2: Algorithms and Problem Solving

Assignment

In this lab, you will write a few more algorithms for Herbie the laundry-picking robot.

How is Herbie doing so far?

As a first step, use the checkerboards handed out by your friendly TA's to trace through your own and your neighbour's prelab psuedocode. The checkerboard is Herbie's room. Herbie can pick up laundry only from the square he is already in. He can see only what is at the edges of the square he is already in, i.e. whether an edge is a wall or not. You might want to refine your algorithm to make sure that Herbie is facing the "right" way before he starts out.

Let's make Herbie work hard for us!

In your cps001 directory, create a directory called lab2 for storing new files related to this lab. Your lab solution should be saved in a file named lab2-solution.txt in the directory you just created, /cps001/lab2. The .txt in your filename indicates that what you have written in your file is plain text, in contrast to last weeks lab where your file had a .html extension (indicating that your file contained information that could be interpreted by a web browser).

The first thing you should include in your solutions is the algorithm you designed in the prelab. If you found and corrected any errors in it when tracing it on the checkerboards, be sure to use the corrected version.

Part A: Problems

For each of the following, write an algorithm to solve the problem, and simulate it on the checkerboard to see if it works. Do the problems in order, as you may find you can use your algorithm from a previous problem as a subroutine in the current problem. You may also write new subroutines if you like. Make sure that your main algorithm and all subroutines are well-specified ... again, remember that a computer only knows what you tell it.

Recall that the following functions are available for Herbie:



Problem 1:

Herbie is in a 5x5 room, and he begins in the lower left hand corner facing East. Write an algorithm that makes him visit every square in the room, picking up laundry as he goes, and go to sleep when he is through.

Problem 2:

Herbie begins in a rectangular room, in the lower left hand corner. The dimensions of the room are unknown, as is the direction he is facing. Have him pick up all the dirty laundry in the room and then go to sleep.

Problem 3:

Herbie is in a rectangular room of unknown dimensions and in some unknown part of the room, facing an unknown direction. Herbie must pick up all the dirty laundry in the room, go back to the same place he started from, and then go to sleep. (This smart Herbie knows how to put himself away!)

Part B: Discussion Questions

Select any three of the following questions. Some of the questions are asking for your informed opinion. They will not be judged as right or wrong, but simply given credit for the amount of thought put into the answer.

Give some thought to all the questions, as you may find them useful for project ideas as well as for your own understanding.

  1. Describe what happened to your algorithm as you took on more and more general problems. What kinds of changes got made? Did you have to start all over, or were you able to use previous algorithms as a starting point? Is your final algorithm much longer or more complicated than your first?

  2. What things would a real-life robot have to deal with that you have been able to ignore? (That is, where is the model we use not the same as real life?) Think about the following to get started: the grid model for the room, friction, physical characteristics of robots (batteries, robotic hands, wheels, etc...) detection capabilities, objects in room.

  3. Imagine that Herbie could "see" squares all around him. Would the problem be easier, harder, or the same to solve? How would Herbie's performance change?

  4. Imagine that Herbie could "see" squares all around him, instead of only the one directly in front of him. How would you break the problem into smaller problems for solving? Give at least 4 steps.

  5. Why don't all houses have robots like Herbie? (After all, the Jetsons had Rosie!)
    You might want to check this out.

  6. Would you like such a robot for your house (assuming of course that it worked well)? Would you like a robot that answered the door? cooked your dinner? babysat your children? In other words, how much do you trust computers/robots/automation? What are your criteria for what you will allow a computer to do for you?

  7. We assumed that Herbie could see dirty laundry. Can you imagine how a robot might actually be able to detect it? You may have very practical answers as well as very creative answers. Think about how a computer might be able to tell laundry from other objects in the room. What assumptions can you make about the nature of dirty laundry? Does your detection scheme work for both a pile of laundry and a single sock?

Submitting

Don't forget to submit you assignment when you are finished. Please note that you have 48 hours to submit your lab and get full credit. If you submit it any later than that, you will get NO credit.

Here is a summary of how to submit: Your file should be named lab2-solution.txt and should be saved in the directory /cps001/lab2. Before you try to submit, make sure you are in the right directory (type "pwd" to check) and that the file is in that directory (type "ls" to check). If you are confident you are in the right place, type:

submit_cps001 lab2/secN lab2-solution.txt
Remember to replace N with your actual section number.


JRNF