CSC 17 Final Assignment Special Edition

BEWARE OF THE WATER's EDGE!

A large, alligator-like creature has recently escaped from a bio-engineering lab and is believed to be hiding inside local lakes and ponds. The creature's alligator DNA was crossed with those of a prehistoric crocodile, a great white shark, and a former computer science professor who has gone mad. It is extremely dangerous. People walking along the water's edge stand a one in ten chance of being attacked.

You are to download the file alligator.java and use that in place of "pathfinder.java". Also download "gator.gif":

Modify your program to avoid being eaten by the mutant alligator.

Note this carefully: You can only be attacked at the water's edge. That is, when you are on land and at least one of the four neighboring coordinates is water. Once you're on the water inside a boat, you'll be safe. It's only the water's edge that's dangerous.

Don't simply avoid the water's edge. Because that may make it impossible to get to the diamond. Instead, the cost of getting close to water should be very high. You'll want the diamond so bad that sometimes it's worth the risk!

You should be aware that the variable *gatorchance* inside class alligator controls the chance of being attacked when you're near water.

When you change the graphics code in alligator.java (to account for different terrain), you need to be aware that this program (in contrast to the simpler pathfinder.java) uses a "triple buffering" technique for animation. There are three buffers. Only one of these is actually visible. There are two other buffers (of type *Image*): clip and dbuf. Corresponding to each buffer is a *Graphics* device for drawing to the buffer:

  • wg: draws to visible buffer, items drawn by this device appears on the screen
  • cg: draws to the clip buffer. This device is used once initially to draw the randomly generated map to the off-screen display buffer, and is also used to draw the red dots that trace the path. The map is basically the static background, and we use a separate buffer to hold it so we won't have to recreate it each time.
  • display: this device draws to the secondary off-screen buffer *dbuf*. It (usually) first draws the clip image buffer, then the animated characters. What does all this mean? It means that to create each individual frame of animation, you would do the following: You will have to figure out other details.

    This assignment should only be done after you have satisfied the minimal requirements. You need to implement The A* algorithm in full.