Electronic handin will be available after 5PM on Thursday.
Our robot, Wally, has been tasked to paint a factory floor dark. There are two ways to paint the floor. One way is to go back and forth, row by row, until the room is painted. Another way is to go around the room painting the edge and continue to spiral in until the room is painted. We need to write programs for Wally for each algorithm and make sure they work correctly before we set Wally loose on a real room.
SET-UP: Download a copy of the GridsAndRobots.zip file. Unzip the file and move the folder GridsAndRobots into your workspace for Eclipse. (If you already downloaded a copy, download a new copy since this file now has a new floor.txt file in it.) Then, using Eclipse, start a new Java project. Select "Create a new project in workspace" and enter the project name GridsAndRobots. You should see a warning at the bottom of the dialog box that says "The wizard will automatically configure the JRE and the project layout based on the existing source." This is ok. This means that Eclipse found a folder with source code in it already so it will start the project with that code. Recall that there is a Robot API that shows what methods you can use to control the robot. For example, to move the robot, you would use the command Robot.move();
For each problem, you will be graded on how general your solution is. You should start by trying to paint the floor given to you in the project folder. But for maximum credit, your program should work for rectangular floors of any size . Also, for maximum credit, your robot should not walk back on to tiles that are already colored dark.
To be successful here, you should start by thinking of the basic algorithm for each problem and try to implement it for the floor given to you to see if the algorithm works correctly. Then create another room and examine if your algorithm will still work. If not, why? How can you change it to cover both rooms? It will really help if you work some of your ideas out on paper first, rather than just typing code and hoping something will work. The logic involved here is not trivial and you will probably need nested loops, so think this through first!
STARTING IDEA FOR ROBOT PAINTER #1: Move the robot while the floor is clear ahead of it. Once this is not possible, move the robot to the next row facing in the opposite direction.
STARTING IDEA FOR ROBOT PAINTER #2: When you move the robot across the bottom row, increment a counter variable for each move so you can determine the length of the room. Do the same with another counter variable as the robot moves up the right side to determine the width of the room. Use this information to control the robot for the rest of the painting.
DO NOT CHANGE ANY CODE IN THE FILES GIVEN TO YOU IN THE PROJECT FOLDER. IF YOUR ALGORITHM DOES NOT WORK, CHANGE YOUR CODE, NOT THE ROBOT OR GRID CODE.
Compile and test that your program runs correctly. If your program does not compile and run, you will not receive full credit for your assignment. We will use additional floors besides the one provided in the project to test your programs.
Your program must contain a comment at the beginning of your program with your name, andrew id, and section.
You should also use standard Java indentation and naming style for identifiers (Examples: ClassName, variableName, methodName()). Starting with this assignment, 1 point will be assigned to this category.
See the course website for instructions on how to hand in your program. Please zip your project folder that is created in Eclipse. This makes it easier for us to grade your work.
Remember that the work you submit must be your own. Also, late hand-ins are not accepted. Please plan ahead and submit early to avoid server overload at the deadline. The deadline is based on the server's clock, not your clock. Please do not email your code to your instructor or course assistant as your official hand-in; these will not be graded.