Computer Science 3675
Fall 2002
Programming Assignment 7

Due: Monday, November 25, 11:59pm

Files

For this assignment, you will need the following files. You might need to use the "save as" feature to save them.

The assignment

For this assignment, look at the Java applet RobotSim.java. It creates two robots of the same kind and moves them around the screen. Each robot must avoid an obstacle, shown as a blue square, and it tries to find a goal, shown by a red square. You can run the applet by using a recent Java-enabled web browser, and visiting RobotSim.html.

The robot that is implemented in RobotSim.java moves in a random direction. You are to replace one of the robots by a robot that uses a different search strategy. Your robot should not use randomization at all, but instead should have a deterministic strategy.

Your robot must use a strategy that will (hopefully) find the goal even if the goal is moved to someplace other that where it is currently, and also if the obstacle is moved. There can be situations where your robot will not find the goal, but try to minimize them. It is not allowed for the robot to look directly at the data concerning the position of the obstacle or the goal. Make the robot search by moving around the screen.

Implement the new robot by extending class Robot. That is, add a new class. You should not need to modify ANY of the code that is present with the exception of the code at the end that creates the robots. Instead of creating two random robots, create one random robot and one of your robots. Also, you can modify the images of the robots if desired.

To compile your program, use the Java compiler, called javac. For example, type

    javac RobotSim.java
The compiler will produces files with extension .class, one for each class in your package.

To run your applet, you can use one of two methods.

  1. Use the appletviewer that comes with the Java Development Kit. Command

        appletviewer -debug RobotSim.html
    
    will run the applet viewer via the Java debugger. When the debugger prompt comes up, type run to run your applet. You can use System.out.println in your program to perform debug prints if you need to.

  2. Put all of your files in a directory and visit RobotSim.html using a Java-enabled web brower. If anything goes wrong, the web browser will not be of much help, and you might have to fall back on the debugger. Also, be careful about the browser using cached copies of your .class files. Sometimes, if you recompile your program, you will inadvertently continue to use the old version in the browser. That will not happen with the applet viewer.

Turning in your assignment

Put your name at the top of the assignment. You did not write all of it, but your wrote some, and I need to see your name anyway. Hand your assignment in as assignment 7 using the handin utility. Hand in RobotSim.java, and any other files that you need or that you have modified, excluding the gif files that are provided to you.