There's a legend at Hofstra University that students who do not show sufficient enthusiasm for their computer science classes will be visited by evil goblins bent on devouring them. Some people dismiss the story as pure myth but there have been reports of a nasty red goblin with sharp, pointed teeth appearing on computer screens.
Your maze solver program will now have to avoid running into the goblin.
You need to first download the new program template mazegob.java, as well as these animated gifs:
You can write the sovle method as described before (you will still call drawdot but a human figure will be drawn instead). But beware that if you ever run into the goblin it's all over. In the program, the goblin is represented by an object called gob1 (of class goblin). The position in the matrix of the goblin is given by gob1.y and gob1.x. You need to rewrite your algorithm so that the position of the human (used to be a dot) (y,x) stays away from the position of the goblin. Initially, the goblin appears in a random cell of the maze that is no less than 8 cells away from the top left-hand corner.
There's a boolean variable called walkthroughwalls inside the class goblin that controls whether the goblin is allowed to walk through walls. By default it's set to false so unless you change this variable the goblin, like the human, can only stay on the "dug out" parts of the maze.
You may find the following function useful (it's in the mazegob class):
public static double dist(int x1, int y1, int x2, int y2)It returns (as a double) the distance between coordinates x1,y1 and x2,y2. The goblin catches you when the distance between the human and goblin is less than or equal to one.
The rest of the assignment is the same.