Computer Science 3675
Summer 2001
Programming Assignment 7

Due: July 27 by end of day. (I will not be available for help after the final exam.)

Files

For this assignment, you will need the following files.

The assignment

Look at the Java applet RobotSim.java. It creates two robots of the same kind and moves them around the screen. The robot must avoid an obstacle, shown as a square, and it tries to find a goal, shown by an X.

The robot that is implemented 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 find the goal even if the goal is moved to someplace other that where it is currently, and also if the obstacle is moved. It is not allowed for the robot to look directly at the data concerning the position of the obstacle or the goal. That is cheating. The robot is only allowed to move a small number of pixels each move. It cannot leap across the page.

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 either use the appletviewer or you can put your robot class in your directory called public_html. (If you don't have such a directory, create one.) Copy file RobotSim.html and the gif files to that directory as well. Be sure that the .class files generated by the Java compiler are in that directory. Then visit http://csci00.math.ecu.edu/~youraccount/RobotSim.html with a web browser, where youraccount is replaced by your account name. The applet should start on its own. Be careful: sometimes, after you update the .class files, the web browser will used cached copies, and so will continue to run the old one. If all else fails, kill the browser and start a new one.

This simulation is very crude. The graphics is simple, and it does not offer you a way to stop the simulation except by going to another page. Enhance it if you like. If you want to make the random robots move a little faster or slower, you can. Fix the wait loop.

Note. If csci00 does not respond to the web browser, then there is something wrong with its http server. Let me know.


Warnings

  1. The applet starts by trying to load the graphics files that are the pictures of the robots. It does not look to see whether the files exist. If the graphics files do not exist, the applet will go into an infinite loop doing nothing. Be sure that the graphics files are there.

  2. If your robot makes an illegal move (such as moving to the left at the left edge of the canvas) the supervisor will ask it to try again. The robot is only given a few chances to fix its move. If it persists in making bad moves, the supervisor puts it back where it was and asks it to make a move again. This can cause a badly designed robot to stall. If your robot crashes into a boundary and just sits there, check how your moves are being made.