Question: A robot is asked to navigate a maze. It is placed at a certain position (the starting position) in the maze and is asked to
A robot is asked to navigate a maze. It is placed at a certain position (the starting position) in the maze and is asked to try to reach another position (the goal position). Positions in the maze will either be open or blocked with an obstacle. Positions are identified by (x,y) coordinates.
At any given moment, the robot can only move 1 step in one of 4 directions. Valid moves are:
Go North: (x,y) -> (x,y-1)
Go East: (x,y) -> (x+1,y)
Go South: (x,y) -> (x,y+1)
Go West: (x,y) -> (x-1,y)
Note that positions are specified in zero-based coordinates (i.e., 0...size-1, where size is the size of the maze in the corresponding dimension).
The robot can only move to positions without obstacles and must stay within the maze.
The robot should search for a path from the starting position to the goal position (a solution path) until it finds one or until it exhausts all possibilities. In addition, it should mark the path it finds (if any) in the maze.
I have created this class for myproject of online bok redaing system.. But it has errors and I dont understand what.. Please help me rectify them
import java.util.Timer; import java.util.TimerTask; import javax.swing.JLabel; import java.util.Calendar; import java.util.Date; import java.text.DateFormat; import javax.swing.JLabel; import java.awt.*; import java.awt.event.*; public class TimerTime { Timer timer; Calendar cal; Date date; DateFormat dateFormatter; /* Constructor used for running example main.*/ public TimerTime(boolean visible,JLabel label,int seconds) { timer = new Timer(); timer.scheduleAtFixedRate(new DoTime(visible,label),0, seconds*1000); } /* Constructor used for creating class in another application */ public TimerTime(int seconds) { this(new JLabel(),seconds); } public TimerTime() { this(new JLabel(),1); } public TimerTime(JLabel label) { this(label, 1); } public TimerTime(JLabel label, int seconds) { timer = new Timer(); timer.scheduleAtFixedRate(new DoTime(label),0, seconds*1000); } class DoTime extends TimerTask { JLabel label = new JLabel(); boolean visible = false; public DoTime(){} public DoTime(boolean visible, JLabel label) { this.label = label; this.visible = visible; } public DoTime(JLabel label){this.label = label; } public void run() { cal = Calendar.getInstance(); date = cal.getTime(); dateFormatter = DateFormat.getTimeInstance(); label.setText(dateFormatter.format(date)); } public void timerCancel()
{ timer.cancel(); } public void timerCancel() { timer.cancel(); } }
Maze
import java.applet.AudioClip; import java.awt.Color; import java.awt.Component; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Point; import java.awt.Toolkit; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.util.ArrayList; import java.util.List; import java.util.Stack; import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.WindowConstants;
public class Maze implements Cloneable { protected static AudioClip applause = AudioUtility.getAudioClip("audio/untie.wav");
private static final int ROOM_SIZE = 40; private static final int WALL_THICKNESS = 6; private static final int MARGIN = 20; private static final boolean debug = false;
protected List rooms = new ArrayList(); protected Dimension dim = null; protected Point offset = null; protected Room curRoom = null; protected Room endRoom = null; protected Stack moves = new Stack(); protected JFrame frame = null; protected boolean initializing = true;
protected Component view;
public Component getView(){ return view; }
public Stack getMoves(){ return moves; }
static class MazeKeyListener extends KeyAdapter { Maze maze;
MazeKeyListener(Maze maze) { this.maze = maze; }
public void keyPressed(KeyEvent e) { System.out.println("Key pressed"); Command command = null; int code = e.getKeyCode(); switch (code) { case KeyEvent.VK_UP: System.out.println("Up key"); command = new MazeMoveCommand(maze, Direction.NORTH); walls.play(); break;
case KeyEvent.VK_DOWN: System.out.println("Down key"); command = new MazeMoveCommand(maze, Direction.SOUTH); walls.play(); break;
case KeyEvent.VK_LEFT: System.out.println("Left key"); command = new MazeMoveCommand(maze, Direction.WEST); walls.play(); break;
case KeyEvent.VK_RIGHT: System.out.println("Right key"); command = new MazeMoveCommand(maze, Direction.EAST); walls.play(); break;
case KeyEvent.VK_ENTER: System.out.println("Enter key"); command = new OpenDoorCommand(maze); dooraud.play(); break;
case (int)'U': case (int)'u' : System.out.println("Undo key"); maze.undoCommand(); break;
default: System.out.println("Key press ignored"); } if (command != null) { maze.doCommand(command); } } }
public void setStartEndRoom(int start, int end){ if(start > 0 && start <= rooms.size()){ Room room = findRoom(start); room.markAsStartRoom(); setCurrentRoom(room); }else{ Room room = findRoom(1); setCurrentRoom(room); room.markAsStartRoom(); } if(end > 0 && end <= rooms.size()){ Room room = findRoom(end); setEndRoom(room); room.markAsEndRoom(); }else{ Room room = findRoom(rooms.size()); setEndRoom(room); room.markAsEndRoom(); } initializing = false; }
public Object clone() throws CloneNotSupportedException { return super.clone(); }
public void addRoom(Room room) { if (room != null) { rooms.add(room); } }
public Room findRoom(int roomNumber) { for (int i = 0; i < rooms.size(); i++) { Room room = (Room) rooms.get(i); if (roomNumber == room.getRoomNumber()) { return room; } } return null; }
public void setCurrentRoom(Room room) { if (room != curRoom) { if (curRoom != null) { curRoom.setInRoom(false); } if (room != null) { room.setInRoom(true); curRoom = room; System.out.println(curRoom); } if (view != null) { view.repaint(); } if(!initializing && curRoom != null && curRoom.isEndRoom()){ if(applause != null) applause.loop(); JOptionPane.showMessageDialog(null, "You have successfully completed the maze !!!", "Awesome", JOptionPane.INFORMATION_MESSAGE); if(applause != null) applause.stop(); frame.dispose(); } } } public void setEndRoom(Room room) { endRoom = room; System.out.println(endRoom); room.setGoalRoom(true); } public Room getCurrentRoom() { return curRoom; } public void move(Direction direction) { if (curRoom != null) { MapSite side = curRoom.getSide(direction); if (side != null) { side.enter(this); } } } public void draw(Graphics g) { if (dim == null) { calculateDimension(); } int dx = MARGIN + -offset.x * ROOM_SIZE; int dy = MARGIN + -offset.y * ROOM_SIZE;
if (debug) { System.out.println("Maze.Draw(): offset=" + offset.x + ", " + offset.y); } // draw rooms first for (int i = 0; i < rooms.size(); i++) { Room room = (Room) rooms.get(i); if (room != null) { Point location = room.getLocation(); if (location != null) {
if (debug) { System.out.println("Maze.Draw(): Room " + room.getRoomNumber() + " location: " + location.x + ", " + location.y); } room.draw(g, dx + location.x * ROOM_SIZE, dy + location.y * ROOM_SIZE, ROOM_SIZE, ROOM_SIZE); } } } // draw walls and doors for (int i = 0; i < rooms.size(); i++) { Room room = (Room) rooms.get(i); if (room != null) { Point location = room.getLocation(); if (location != null) { for (Direction dir = Direction.first(); dir != null; dir = dir.next()) { MapSite side = room.getSide(dir); if (side != null) { if (dir == Direction.NORTH) { side.draw(g, dx + location.x * ROOM_SIZE - WALL_THICKNESS / 2, dy + location.y * ROOM_SIZE - WALL_THICKNESS / 2, ROOM_SIZE + WALL_THICKNESS, WALL_THICKNESS); } else if (dir == Direction.EAST) { side.draw(g, dx + location.x * ROOM_SIZE + ROOM_SIZE - WALL_THICKNESS / 2, dy + location.y * ROOM_SIZE - WALL_THICKNESS / 2, WALL_THICKNESS, ROOM_SIZE + WALL_THICKNESS); } else if (dir == Direction.SOUTH) { side.draw(g, dx + location.x * ROOM_SIZE - WALL_THICKNESS / 2, dy + location.y * ROOM_SIZE + ROOM_SIZE - WALL_THICKNESS / 2, ROOM_SIZE + WALL_THICKNESS, WALL_THICKNESS); } else { side.draw(g, dx + location.x * ROOM_SIZE - WALL_THICKNESS / 2, dy + location.y * ROOM_SIZE - WALL_THICKNESS / 2, WALL_THICKNESS, ROOM_SIZE + WALL_THICKNESS); } } } } } } }
public Dimension getDimension() { if (dim == null) { calculateDimension(); } return dim; }
protected void calculateDimension() { if (rooms.size() > 0) { int minX = 0, maxX = 0, minY = 0, maxY = 0; Room room = (Room) rooms.get(0); room.setLocation(new Point(0, 0)); boolean changed = true; while (changed && !isAllRoomsSet()) { changed = false; for (int i = 0; i < rooms.size(); i++) { room = (Room) rooms.get(i); Point location = room.getLocation(); if (location != null) { for (Direction dir = Direction.first(); dir != null; dir = dir.next()) { MapSite side = room.getSide(dir); if (side instanceof Door) { Door door = (Door) side; Room otherSide = door.otherSideFrom(room); if (otherSide != null && otherSide.getLocation() == null) { if (dir == Direction.NORTH) { otherSide.setLocation(new Point(location.x, location.y - 1)); minY = Math.min(minY, location.y - 1); } else if (dir == Direction.EAST) { otherSide.setLocation(new Point(location.x + 1, location.y)); maxX = Math.max(maxX, location.x + 1); } else if (dir == Direction.SOUTH) { otherSide.setLocation(new Point(location.x, location.y + 1)); maxY = Math.max(maxY, location.y + 1); } else { otherSide.setLocation(new Point(location.x - 1, location.y)); minX = Math.min(minX, location.x - 1); } changed = true; } } } } } } offset = new Point(minX, minY); dim = new Dimension(maxX - minX + 1, maxY - minY + 1); } else { offset = new Point(0, 0); dim = new Dimension(0, 0); } }
protected boolean isAllRoomsSet() { for (int i = 0; i < rooms.size(); i++) { Room room = (Room) rooms.get(i); if (room.getLocation() == null) { return false; } } return true; }
protected void setView(Component view) { this.view = view; }
protected void doCommand(Command command) { if (command != null){ moves.push(command); command.execute(); } }
protected void undoCommand() { if (!moves.empty()) { Object top = moves.peek(); // looking at the top element without popping it if (top instanceof UndoableCommand) { moves.pop(); UndoableCommand undoableCommand = (UndoableCommand) top; undoableCommand.undo(); } } }
public void disposeFrame(){ if(frame != null){ frame.dispose(); } }
public void showFrame(String frameTitle) { frame = new JFrame(frameTitle); frame.setContentPane(new Maze.MazePanel(this)); frame.pack(); Dimension frameDim = frame.getSize(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); frame.setLocation(screenSize.width/2 - frameDim.width/2, screenSize.height/2 - frameDim.height/2); frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); frame.setVisible(true); }
static class MazePanel extends JPanel { private static final long serialVersionUID = 6600808034263523518L; private Maze maze; private Dimension dim;
MazePanel(Maze maze) { this.maze = maze; if (maze != null) { maze.setView(this); Dimension d = maze.getDimension(); if (d != null) { dim = new Dimension(d.width * ROOM_SIZE + 2 * MARGIN, d.height * ROOM_SIZE + 2 * MARGIN); } addKeyListener(new MazeKeyListener(maze)); } }
public void paint(Graphics g) { Dimension d = getSize(); g.setColor(Color.white); g.fillRect(0, 0, d.width, d.height); if (maze != null) { maze.draw(g); } requestFocus(); }
public boolean isFocusable() { return true; }
public Dimension getPreferredSize() { return dim; }
public Dimension getMinimumSize() { return dim; } }
public void setGameComplete(boolean b) { // TODO Auto-generated method stub }
public boolean isGameComplete() { // TODO Auto-generated method stub return false; }
public int getLastRoomNumber() { // TODO Auto-generated method stub return 0; }
protected static AudioClip dooraud = AudioUtility.getAudioClip("door.wav"); protected static AudioClip walls = AudioUtility.getAudioClip("walls.wav");
}
Room
import java.awt.*; import java.applet.AudioClip;
@SuppressWarnings("unused") public class Room implements MapSite {
public static final Color ROOM_COLOR = new Color(252, 251, 152); public static final Color PLAYER_COLOR = Color.red;
public Room(int roomNumber) { this.roomNumber = roomNumber; }
public Object clone() throws CloneNotSupportedException { Room room = (Room) super.clone(); room.sides = new MapSite[4]; for (int i = 0; i < 4; i++) { if (sides[i] != null) { room.sides[i] = (MapSite) sides[i].clone(); } } return room; } public MapSite getSide(Direction dir) { if (dir != null) { return sides[dir.getOrdinal()]; } return null; }
public void setSide(Direction dir, MapSite site) { if (dir != null) { sides[dir.getOrdinal()] = site; if (site instanceof Door) { Door door = (Door) site; if (dir == Direction.NORTH || dir == Direction.SOUTH) { door.setOrientation(Orientation.HORIZONTAL); } else { door.setOrientation(Orientation.VERTICAL); } } } } public void setRoomNumber(int roomNumber) { this.roomNumber = roomNumber; }
public int getRoomNumber() { return roomNumber; }
public Point getLocation() { return location; }
public void setLocation(Point location) { this.location = location; }
public void enter(Maze maze) { maze.setCurrentRoom(this); if(this.goalroom){ complete.play(); maze.setGameComplete(true); } else { if (maze.isGameComplete()){ complete.stop(); // doubletake.play(); } else gong.play(); } }
public boolean isInRoom() { return inroom; }
public void setInRoom(boolean inroom) { this.inroom = inroom; }
public void setGoalRoom (boolean goalroom){ this.goalroom = goalroom; }
public void draw(Graphics g, int x, int y, int w, int h) { g.setColor(ROOM_COLOR); g.fillRect(x, y, w, h); if (inroom) { g.setColor(PLAYER_COLOR); g.fillOval(x + w / 2 - 5, y + h / 2 - 5, 10, 10); } if (goalroom) { g.setColor(Color.magenta); g.setFont (new Font ("Maiandra ",Font.BOLD, 22)); //g.drawString("D",x,y); g.fillRect(x, y, w, h); } }
protected int roomNumber = 0; protected boolean inroom = false; protected boolean goalroom=false; protected MapSite[] sides = new MapSite[4]; protected Point location = null;
public boolean isEndRoom() { // TODO Auto-generated method stub return false; }
public void markAsStartRoom() { // TODO Auto-generated method stub }
public void markAsEndRoom() { // TODO Auto-generated method stub }
protected static AudioClip gong = AudioUtility.getAudioClip("enter_room.wav"); protected static AudioClip complete = AudioUtility.getAudioClip("applause.wav"); }
MazeGameBuilder
import java.awt.*; import javax.swing.*;
@SuppressWarnings("unused") public class MazeGameBuilder {
public static Maze createMaze(MazeBuilder builder) { builder.newMaze(); //Added below code to create all 20 rooms builder.buildRooms(20); //Added code below to handle maze of size 20 rooms builder.buildDoor(1, 2, Direction.WEST, true); builder.buildDoor(2, 3, Direction.WEST, false); builder.buildDoor(3, 4, Direction.WEST, false); builder.buildDoor(5, 6, Direction.WEST, true); builder.buildDoor(6, 7, Direction.WEST, true); builder.buildDoor(7, 8, Direction.WEST, true); builder.buildDoor(5, 9, Direction.NORTH, false); builder.buildDoor(6, 10, Direction.NORTH, true); builder.buildDoor(11, 15, Direction.NORTH, false); builder.buildDoor(15, 19, Direction.NORTH, false); builder.buildDoor(10, 11, Direction.WEST, true); builder.buildDoor(11, 12, Direction.WEST, true); builder.buildDoor(1, 5, Direction.NORTH, true); builder.buildDoor(13, 14, Direction.WEST, true); builder.buildDoor(14, 15, Direction.WEST, true); builder.buildDoor(15, 16, Direction.WEST, false); builder.buildDoor(10, 14, Direction.NORTH, true); builder.buildDoor(9, 13, Direction.NORTH, true); builder.buildDoor(3, 7, Direction.NORTH, true); builder.buildDoor(17, 18, Direction.WEST, true); builder.buildDoor(18, 19, Direction.WEST, true); builder.buildDoor(19, 20, Direction.WEST, true); //Set the Room which is to be the Goal Room builder.getMaze().findRoom(20).setGoalRoom(true); return builder.getMaze(); }
/*public static void main(String[] args) { Maze maze; MazeBuilder builder; MazeFactory factory = null;
if (args.length > 0) { if ("Harry".equals(args[0])) { factory = new HarryPotterMazeFactory(); } else if ("Snow".equals(args[0])) { factory = new SnowWhiteMazeFactory(); } else if ("Default".equals(args[0])) { factory = new MazeFactory(); } } if (factory != null) { builder = new FactoryMazeBuilder(factory); } else { builder = new SimpleMazeBuilder(); } maze = createMaze(builder); maze.setCurrentRoom(1);
JFrame frame; frame = new JFrame("Maze -- Builder"); frame.setContentPane(new Maze.MazePanel(maze)); frame.pack(); Dimension frameDim = frame.getSize(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); frame.setLocation(screenSize.width / 2 - frameDim.width / 2, screenSize.height / 2 - frameDim.height / 2); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.setVisible(true); } */ }
Wall
import java.awt.*; import java.applet.AudioClip;
@SuppressWarnings("unused") public class Wall implements MapSite {
public static final Color WALL_COLOR = Color.gray;
public Object clone() throws CloneNotSupportedException { return super.clone(); }
public void enter(Maze maze) { //hurts.play(); }
public void draw(Graphics g, int x, int y, int w, int h) { g.setColor(WALL_COLOR); g.fillRect(x, y, w, h); }
// protected static AudioClip hurts = AudioUtility.getInstance().getAudioClip("ow.wav");
}
UndoableCommand
public interface UndoableCommand extends Command {
public void undo();
}
Orientation
public class Orientation {
public static final Orientation VERTICAL = new Orientation("Vertical"); public static final Orientation HORIZONTAL = new Orientation("Horizontal");
public String toString() { return name; }
private Orientation(String name) { this.name = name; } private final String name;
}
OpenDoorCommand
public class OpenDoorCommand implements UndoableCommand { private final Maze maze; /** * Creates a new command. * @param maze the maze to affect */ public OpenDoorCommand(Maze maze) { this.maze = maze; } // get current room and invert any adjacent doors @Override public void execute() { Door door = null; // open all doors Direction d = Direction.first(); while (d != null) { MapSite m = maze.getCurrentRoom().getSide(d); if (m instanceof Door) { door = ((Door) m); door.setOpen(!door.isOpen()); } d = d.next(); } // if( door != null ) ((Object) AudioUtility.PLAY( Door.AudioUrl)).play(); if( maze.view != null ) maze.view.repaint(); } // refer to execute() @Override public void undo() { execute(); } } MazeOpenDoorCommand public class MazeOpenDoorCommand implements UndoableCommand {
public MazeOpenDoorCommand(Maze maze) { this.maze = maze; }
public void execute() { Room currRoom = maze.getCurrentRoom(); Direction dir = Direction.first(); while (dir != null){ MapSite m = currRoom.getSide(dir); if (m instanceof Door){ ((Door)m).setOpen(true); currRoom.setSide(dir, m); } dir = dir.next(); } }
public void undo() {}
protected Maze maze;
}
MazeMoveCommand
public class MazeMoveCommand implements UndoableCommand {
public MazeMoveCommand(Maze maze, Direction direction) { this.maze = maze; this.direction = direction; }
public void execute() { maze.move(direction); }
public void undo() { maze.move(direction.opposite()); }
protected Maze maze; protected Direction direction;
}
MazeFactory
public class MazeFactory {
public Maze makeMaze() { return new Maze(); }
public Wall makeWall() { return new Wall(); }
public Room makeRoom(int roomNumber) { return new Room(roomNumber); }
public Door makeDoor(Room room1, Room room2) { return new Door(room1, room2); }
}
Command
public interface Command {
public void execute();
}
AudioUtility
import java.applet.Applet; import java.applet.AudioClip; import java.net.MalformedURLException; import java.net.URL;
public class AudioUtility { public static final AudioClip getAudioClip(String filename) { if (filename != null) { try { return Applet.newAudioClip(new URL("http://harp.njit.edu/~dkk8/cs602/cs602all/Assignments/Assignment10/" + filename)); } catch (MalformedURLException e) { e.printStackTrace(); } } return null; }
public static Object PLAY(String audiourl) { // TODO Auto-generated method stub return null; }
}
CustomMazeBuilder
import java.util.ArrayList; import java.util.List; /*import maze.Direction; import maze.MapSite; import maze.Maze; import maze.Door; import maze.MazeFactory; import maze.Room;*/
public class CustomMazeBuilder { private static int randomInt(int i){ return (int)((double)i * Math.random()); } private static void setStartEnd(Maze maze, int cols, int rows) { int startRoom = 0; int endRoom = 0;
switch(randomInt(4)) { case 0: startRoom = 1; endRoom = cols * rows; break; case 1: startRoom = cols; endRoom = (cols * (rows - 1)) + 1; break; case 2: startRoom = cols * rows; endRoom = 1; break; case 3: startRoom = (cols * (rows - 1)) + 1; endRoom = cols; break; } maze.setStartEndRoom(startRoom, endRoom); }
private static void setOpenableDoors(Maze maze, int cols, int rows) { List allDoors = new ArrayList(); int totalRooms = cols * rows; for(int i=1; i <= totalRooms; i++){ Room room = maze.findRoom(i); for (Direction dir = Direction.first(); dir != null; dir = dir.next()) { MapSite side = room.getSide(dir); if(side instanceof Door){ allDoors.add((Door)side); } } } for(int i=0; i < allDoors.size(); i++){ if(i%4==0){ Door door = (Door)allDoors.get(i); door.setOpen(false); } } } public static Maze makeMaze(int cols, int rows, MazeFactory factory) { Maze maze = factory.makeMaze();
int totalRooms = cols * rows; for(int i=1; i <= totalRooms; i++){ Room room = factory.makeRoom(i); for (Direction dir = Direction.first(); dir != null; dir = dir.next()) { room.setSide(dir, factory.makeWall()); } maze.addRoom(room); }
int [][] m = new int[cols][rows]; for(int i = 0; i < cols; i++) { for(int j = 0; j < rows; j++) { m[i][j] |= 15; //Initialize room
if(j == 0) // First row m[i][0] |= 16;
if(i == cols - 1) // Last column m[i][j] |= 32;
if(j == rows - 1) // Last row m[i][j] |= 64;
if(i == 0) // First Column m[0][j] |= 128; } } int ai[] = new int[4]; int l = randomInt(cols); int i1 = randomInt(rows); int stackPtr = 0; int [] stack = new int[totalRooms];
for(int i = 1; i < totalRooms;) { int j = 0; if((m[l][i1] & 16) == 0 && (m[l][i1 - 1] & 15) == 15) ai[j++] = 0; if((m[l][i1] & 32) == 0 && (m[l + 1][i1] & 15) == 15) ai[j++] = 1; if((m[l][i1] & 64) == 0 && (m[l][i1 + 1] & 15) == 15) ai[j++] = 2; if((m[l][i1] & 128) == 0 && (m[l - 1][i1] & 15) == 15) ai[j++] = 3; if(j != 0) { int k = ai[randomInt(j)]; stack[stackPtr++] = k;
// l = col number // i1 = row number Direction dir = null; int room1 = (i1 * cols) + l + 1; int room2 = 0; switch(k) { case 0: dir = Direction.SOUTH; room2 = room1-cols; break; case 1: dir = Direction.EAST; room2 = room1 + 1; break; case 2: dir = Direction.NORTH; room2 = room1 + cols; break; case 3: dir = Direction.WEST; room2 = room1 - 1; break; }
Room roomObj1 = maze.findRoom(room1); Room roomObj2 = maze.findRoom(room2); Door door = factory.makeDoor(roomObj1, roomObj2); roomObj1.setSide(dir, door); roomObj2.setSide(dir.opposite(), door); door.setOpen(true);
switch(k) { case 0: m[l][i1] &= -2; m[l][--i1] &= -5; break;
case 1: m[l][i1] &= -3; m[++l][i1] &= -9; break; case 2: m[l][i1] &= -5; m[l][++i1] &= -2; break;
case 3: m[l][i1] &= -9; m[--l][i1] &= -3; break; } i++; } else { switch(stack[--stackPtr]) { case 0: i1++; break; case 1: l--; break;
case 2: i1--; break;
case 3: l++; break; } } }
setStartEnd(maze, cols, rows); setOpenableDoors(maze, cols, rows); return maze; } }
MapSite
import java.awt.*;
public interface MapSite extends Cloneable {
public Object clone() throws CloneNotSupportedException; public void enter(Maze maze); public void draw(Graphics g, int x, int y, int w, int h);
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
