<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://www.lensovet.net/~sysadmin/w/index.php?action=history&amp;feed=atom&amp;title=Computer_Science%2F61b%2FHomework%2Fhw9%2FMaze.java</id>
	<title>Computer Science/61b/Homework/hw9/Maze.java - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://www.lensovet.net/~sysadmin/w/index.php?action=history&amp;feed=atom&amp;title=Computer_Science%2F61b%2FHomework%2Fhw9%2FMaze.java"/>
	<link rel="alternate" type="text/html" href="http://www.lensovet.net/~sysadmin/w/index.php?title=Computer_Science/61b/Homework/hw9/Maze.java&amp;action=history"/>
	<updated>2026-05-02T21:34:04Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.31.16</generator>
	<entry>
		<id>http://www.lensovet.net/~sysadmin/w/index.php?title=Computer_Science/61b/Homework/hw9/Maze.java&amp;diff=24385&amp;oldid=prev</id>
		<title>Lensovet: Lensovet moved page CS/61b/Homework/hw9/Maze.java to Computer Science/61b/Homework/hw9/Maze.java</title>
		<link rel="alternate" type="text/html" href="http://www.lensovet.net/~sysadmin/w/index.php?title=Computer_Science/61b/Homework/hw9/Maze.java&amp;diff=24385&amp;oldid=prev"/>
		<updated>2023-02-20T03:51:36Z</updated>

		<summary type="html">&lt;p&gt;Lensovet moved page &lt;a href=&quot;/~sysadmin/w/CS/61b/Homework/hw9/Maze.java&quot; class=&quot;mw-redirect&quot; title=&quot;CS/61b/Homework/hw9/Maze.java&quot;&gt;CS/61b/Homework/hw9/Maze.java&lt;/a&gt; to &lt;a href=&quot;/~sysadmin/w/Computer_Science/61b/Homework/hw9/Maze.java&quot; title=&quot;Computer Science/61b/Homework/hw9/Maze.java&quot;&gt;Computer Science/61b/Homework/hw9/Maze.java&lt;/a&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 03:51, 20 February 2023&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Lensovet</name></author>
		
	</entry>
	<entry>
		<id>http://www.lensovet.net/~sysadmin/w/index.php?title=Computer_Science/61b/Homework/hw9/Maze.java&amp;diff=4073&amp;oldid=prev</id>
		<title>Lensovet: moved CS 61b/Homework/hw9/Maze.java to CS/61b/Homework/hw9/Maze.java:&amp;#32;fix cs 61b hierarchy</title>
		<link rel="alternate" type="text/html" href="http://www.lensovet.net/~sysadmin/w/index.php?title=Computer_Science/61b/Homework/hw9/Maze.java&amp;diff=4073&amp;oldid=prev"/>
		<updated>2010-11-14T06:00:20Z</updated>

		<summary type="html">&lt;p&gt;moved &lt;a href=&quot;/~sysadmin/w/CS_61b/Homework/hw9/Maze.java&quot; class=&quot;mw-redirect&quot; title=&quot;CS 61b/Homework/hw9/Maze.java&quot;&gt;CS 61b/Homework/hw9/Maze.java&lt;/a&gt; to &lt;a href=&quot;/~sysadmin/w/CS/61b/Homework/hw9/Maze.java&quot; class=&quot;mw-redirect&quot; title=&quot;CS/61b/Homework/hw9/Maze.java&quot;&gt;CS/61b/Homework/hw9/Maze.java&lt;/a&gt;: fix cs 61b hierarchy&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 06:00, 14 November 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Lensovet</name></author>
		
	</entry>
	<entry>
		<id>http://www.lensovet.net/~sysadmin/w/index.php?title=Computer_Science/61b/Homework/hw9/Maze.java&amp;diff=3241&amp;oldid=prev</id>
		<title>Lensovet at 06:37, 22 September 2007</title>
		<link rel="alternate" type="text/html" href="http://www.lensovet.net/~sysadmin/w/index.php?title=Computer_Science/61b/Homework/hw9/Maze.java&amp;diff=3241&amp;oldid=prev"/>
		<updated>2007-09-22T06:37:39Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{code}}&lt;br /&gt;
 /* Maze.java */&lt;br /&gt;
 &lt;br /&gt;
 import java.util.*;&lt;br /&gt;
 import set.*;&lt;br /&gt;
 &lt;br /&gt;
 /**&lt;br /&gt;
  *  The Maze class represents a maze in a rectangular grid.  There is exactly&lt;br /&gt;
  *  one path between any two points.&lt;br /&gt;
  **/&lt;br /&gt;
 &lt;br /&gt;
 public class Maze {&lt;br /&gt;
 	&lt;br /&gt;
 	// Horizontal and vertical dimensions of the maze.&lt;br /&gt;
 	protected int horiz;&lt;br /&gt;
 	protected int vert;&lt;br /&gt;
 	// Horizontal and vertical interior walls; each is true if the wall exists.&lt;br /&gt;
 	protected boolean[][] hWalls;&lt;br /&gt;
 	protected boolean[][] vWalls;&lt;br /&gt;
 	&lt;br /&gt;
 	// Object for generting random numbers.&lt;br /&gt;
 	private static Random random;&lt;br /&gt;
 	&lt;br /&gt;
 	// Constants used in depth-first search (which checks for cycles in the&lt;br /&gt;
 	// maze).&lt;br /&gt;
 	private static final int STARTHERE = 0;&lt;br /&gt;
 	private static final int FROMLEFT = 1;&lt;br /&gt;
 	private static final int FROMRIGHT = 2;&lt;br /&gt;
 	private static final int FROMABOVE = 3;&lt;br /&gt;
 	private static final int FROMBELOW = 4;&lt;br /&gt;
 	&lt;br /&gt;
 	protected DisjointSets cells;&lt;br /&gt;
 	&lt;br /&gt;
 	private int targetind(int x, int y) {&lt;br /&gt;
 		return (x*vert)+y;&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 	/**&lt;br /&gt;
 	 *  Maze() creates a rectangular maze having &amp;quot;horizontalSize&amp;quot; cells in the&lt;br /&gt;
 	 *  horizontal direction, and &amp;quot;verticalSize&amp;quot; cells in the vertical direction.&lt;br /&gt;
 	 *  There is a path between any two cells of the maze.  A disjoint set data&lt;br /&gt;
 	 *  structure is used to ensure that there is only one path between any two&lt;br /&gt;
 	 *  cells.&lt;br /&gt;
 	 **/&lt;br /&gt;
 	public Maze(int horizontalSize, int verticalSize) {&lt;br /&gt;
 		int i, j;&lt;br /&gt;
 		&lt;br /&gt;
 		horiz = horizontalSize;&lt;br /&gt;
 		vert = verticalSize;&lt;br /&gt;
 		if ((horiz &amp;lt; 1) || (vert &amp;lt; 1) || ((horiz == 1) &amp;amp;&amp;amp; (vert == 1))) {&lt;br /&gt;
 			return;     // There are no interior walls&lt;br /&gt;
 		}&lt;br /&gt;
 		&lt;br /&gt;
 		// Create all of the horizontal interior walls.  Initially, every&lt;br /&gt;
 		// horizontal wall exists; they will be removed later by the maze&lt;br /&gt;
 		// generation algorithm.&lt;br /&gt;
 		if (vert &amp;gt; 1) {&lt;br /&gt;
 			hWalls = new boolean[horiz][vert - 1];&lt;br /&gt;
 			for (j = 0; j &amp;lt; vert - 1; j++) {&lt;br /&gt;
 				for (i = 0; i &amp;lt; horiz; i++) {&lt;br /&gt;
 					hWalls[i][j] = true;&lt;br /&gt;
 				}&lt;br /&gt;
 			}&lt;br /&gt;
 		}&lt;br /&gt;
 		// Create all of the vertical interior walls.&lt;br /&gt;
 		if (horiz &amp;gt; 1) {&lt;br /&gt;
 			vWalls = new boolean[horiz - 1][vert];&lt;br /&gt;
 			for (i = 0; i &amp;lt; horiz - 1; i++) {&lt;br /&gt;
 				for (j = 0; j &amp;lt; vert; j++) {&lt;br /&gt;
 					vWalls[i][j] = true;&lt;br /&gt;
 				}&lt;br /&gt;
 			}&lt;br /&gt;
 		}&lt;br /&gt;
 		&lt;br /&gt;
 		// create new DjSet with all cells&lt;br /&gt;
 		cells = new DisjointSets(horiz*vert);&lt;br /&gt;
 		&lt;br /&gt;
 		// make an array of all the walls&lt;br /&gt;
 		Wall[] wallar = new Wall[horiz*(vert-1) + (horiz-1)*vert];&lt;br /&gt;
 		int ii=0;&lt;br /&gt;
 		for (int a=0; a&amp;lt;horiz-1; a++) {&lt;br /&gt;
 			for (int b=0; b&amp;lt;vert; b++) {&lt;br /&gt;
 				wallar[ii] = new Wall(a, b, Wall.V);&lt;br /&gt;
 				ii++;&lt;br /&gt;
 			}&lt;br /&gt;
 		}&lt;br /&gt;
 		for (int a=0; a&amp;lt;horiz; a++) {&lt;br /&gt;
 			for (int b=0; b&amp;lt;vert-1; b++) {&lt;br /&gt;
 				wallar[ii] = new Wall(a, b, Wall.H);&lt;br /&gt;
 				ii++;&lt;br /&gt;
 			}&lt;br /&gt;
 		}&lt;br /&gt;
 		&lt;br /&gt;
 		// now randomize their order&lt;br /&gt;
 		for (int w=wallar.length; w&amp;gt;1; w--) {&lt;br /&gt;
 			int targetindex = randInt(w);&lt;br /&gt;
 			Wall targetswap = wallar[targetindex];&lt;br /&gt;
 			wallar[targetindex] = wallar[w-1];&lt;br /&gt;
 			wallar[w-1] = targetswap;&lt;br /&gt;
 		}&lt;br /&gt;
 		&lt;br /&gt;
 		// now remove the walls if the cells they separate have no connection between them&lt;br /&gt;
 		for (ii=0; ii&amp;lt;wallar.length; ii++) {&lt;br /&gt;
 			Wall curwall = wallar[ii];&lt;br /&gt;
 			int cell1x, cell1y, cell2x, cell2y;&lt;br /&gt;
 			cell1x = curwall.x; // left or top&lt;br /&gt;
 			cell1y = curwall.y;&lt;br /&gt;
 			if (curwall.kind == Wall.H) { // horizontal wall&lt;br /&gt;
 				cell2x = cell1x; // bottom&lt;br /&gt;
 				cell2y = cell1y+1;&lt;br /&gt;
 			} else { // vertical wall&lt;br /&gt;
 				cell2x = cell1x+1; // right&lt;br /&gt;
 				cell2y = cell1y;&lt;br /&gt;
 			}&lt;br /&gt;
 			int rootc1 = cells.find(targetind(cell1x, cell1y));&lt;br /&gt;
 			int rootc2 = cells.find(targetind(cell2x, cell2y));&lt;br /&gt;
 			if (rootc1 != rootc2) {&lt;br /&gt;
 				if (curwall.kind == Wall.H) {&lt;br /&gt;
 					hWalls[curwall.x][curwall.y] = false;&lt;br /&gt;
 				} else {&lt;br /&gt;
 					vWalls[curwall.x][curwall.y] = false;&lt;br /&gt;
 				}&lt;br /&gt;
 				cells.union(rootc1, rootc2);&lt;br /&gt;
 			}&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 	/**&lt;br /&gt;
 	 *  toString() returns a string representation of the maze.&lt;br /&gt;
 	 **/&lt;br /&gt;
 	public String toString() {&lt;br /&gt;
 		int i, j;&lt;br /&gt;
 		String s = &amp;quot;&amp;quot;;&lt;br /&gt;
 		&lt;br /&gt;
 		// Print the top exterior wall.&lt;br /&gt;
 		for (i = 0; i &amp;lt; horiz; i++) {&lt;br /&gt;
 			s = s + &amp;quot;**&amp;quot;;&lt;br /&gt;
 		}&lt;br /&gt;
 		s = s + &amp;quot;*\n*&amp;quot;;&lt;br /&gt;
 		&lt;br /&gt;
 		// Print the maze interior.&lt;br /&gt;
 		for (j = 0; j &amp;lt; vert; j++) {&lt;br /&gt;
 			// Print a row of cells and vertical walls.&lt;br /&gt;
 			for (i = 0; i &amp;lt; horiz - 1; i++) {&lt;br /&gt;
 				if (vWalls[i][j]) {&lt;br /&gt;
 					s = s + &amp;quot; *&amp;quot;;&lt;br /&gt;
 				} else {&lt;br /&gt;
 					s = s + &amp;quot;  &amp;quot;;&lt;br /&gt;
 				}&lt;br /&gt;
 			}&lt;br /&gt;
 			s = s + &amp;quot; *\n*&amp;quot;;&lt;br /&gt;
 			if (j &amp;lt; vert - 1) {&lt;br /&gt;
 				// Print a row of horizontal walls and wall corners.&lt;br /&gt;
 				for (i = 0; i &amp;lt; horiz; i++) {&lt;br /&gt;
 					if (hWalls[i][j]) {&lt;br /&gt;
 						s = s + &amp;quot;**&amp;quot;;&lt;br /&gt;
 					} else {&lt;br /&gt;
 						s = s + &amp;quot; *&amp;quot;;&lt;br /&gt;
 					}&lt;br /&gt;
 				}&lt;br /&gt;
 				s = s + &amp;quot;\n*&amp;quot;;&lt;br /&gt;
 			}&lt;br /&gt;
 		}&lt;br /&gt;
 		&lt;br /&gt;
 		// Print the bottom exterior wall.  (Note that the first asterisk has&lt;br /&gt;
 		// already been printed.)&lt;br /&gt;
 		for (i = 0; i &amp;lt; horiz; i++) {&lt;br /&gt;
 			s = s + &amp;quot;**&amp;quot;;&lt;br /&gt;
 		}&lt;br /&gt;
 		return s + &amp;quot;\n&amp;quot;;&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 	/**&lt;br /&gt;
 	 * horizontalWall() determines whether the horizontal wall on the bottom&lt;br /&gt;
 	 * edge of cell (x, y) exists.  If the coordinates (x, y) do not correspond&lt;br /&gt;
 	 * to an interior wall, true is returned.&lt;br /&gt;
 	 **/&lt;br /&gt;
 	public boolean horizontalWall(int x, int y) {&lt;br /&gt;
 		if ((x &amp;lt; 0) || (y &amp;lt; 0) || (x &amp;gt; horiz - 1) || (y &amp;gt; vert - 2)) {&lt;br /&gt;
 			return true;&lt;br /&gt;
 		}&lt;br /&gt;
 		return hWalls[x][y];&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 	/**&lt;br /&gt;
 	 * verticalWall() determines whether the vertical wall on the right edge of&lt;br /&gt;
 	 * cell (x, y) exists. If the coordinates (x, y) do not correspond to an&lt;br /&gt;
 	 * interior wall, true is returned.&lt;br /&gt;
 	 **/&lt;br /&gt;
 	public boolean verticalWall(int x, int y) {&lt;br /&gt;
 		if ((x &amp;lt; 0) || (y &amp;lt; 0) || (x &amp;gt; horiz - 2) || (y &amp;gt; vert - 1)) {&lt;br /&gt;
 			return true;&lt;br /&gt;
 		}&lt;br /&gt;
 		return vWalls[x][y];&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 	/**&lt;br /&gt;
 	 * randInt() returns a random integer from 0 to choices - 1.&lt;br /&gt;
 	 **/&lt;br /&gt;
 	private static int randInt(int choices) {&lt;br /&gt;
 		if (random == null) {       // Only executed first time randInt() is called&lt;br /&gt;
 			random = new Random();  // Create a &amp;quot;Random&amp;quot; object with random seed&lt;br /&gt;
 		}&lt;br /&gt;
 		int r = random.nextInt() % choices;  // From 1 - choices to choices - 1&lt;br /&gt;
 		if (r &amp;lt; 0) {&lt;br /&gt;
 			r = -r;                          // From 0 to choices - 1&lt;br /&gt;
 		}&lt;br /&gt;
 		return r;&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 	/**&lt;br /&gt;
 	 * diagnose() checks the maze and prints a warning if not every cell can be&lt;br /&gt;
 	 * reached from the upper left corner cell, or if there is a cycle reachable&lt;br /&gt;
 	 * from the upper left cell.&lt;br /&gt;
 	 *&lt;br /&gt;
 	 * DO NOT CHANGE THIS METHOD.  Your code is expected to work with our copy&lt;br /&gt;
 	 * of this method.&lt;br /&gt;
 	 **/&lt;br /&gt;
 	protected void diagnose() {&lt;br /&gt;
 		if ((horiz &amp;lt; 1) || (vert &amp;lt; 1) || ((horiz == 1) &amp;amp;&amp;amp; (vert == 1))) {&lt;br /&gt;
 			return;                                    // There are no interior walls&lt;br /&gt;
 		}&lt;br /&gt;
 		&lt;br /&gt;
 		boolean mazeFine = true;&lt;br /&gt;
 		&lt;br /&gt;
 		// Create an array that indicates whether each cell has been visited during&lt;br /&gt;
 		// a depth-first traversal.&lt;br /&gt;
 		boolean[][] cellVisited = new boolean[horiz][vert];&lt;br /&gt;
 		// Do a depth-first traversal.&lt;br /&gt;
 		if (depthFirstSearch(0, 0, STARTHERE, cellVisited)) {&lt;br /&gt;
 			System.out.println(&amp;quot;Your maze has a cycle.&amp;quot;);&lt;br /&gt;
 			mazeFine = false;&lt;br /&gt;
 		}&lt;br /&gt;
 		&lt;br /&gt;
 		// Check to be sure that every cell of the maze was visited.&lt;br /&gt;
 outerLoop:&lt;br /&gt;
 			for (int j = 0; j &amp;lt; vert; j++) {&lt;br /&gt;
 				for (int i = 0; i &amp;lt; horiz; i++) {&lt;br /&gt;
 					if (!cellVisited[i][j]) {&lt;br /&gt;
 						System.out.println(&amp;quot;Not every cell in your maze is reachable from &amp;quot; +&lt;br /&gt;
 										   &amp;quot;every other cell.&amp;quot;);&lt;br /&gt;
 						mazeFine = false;&lt;br /&gt;
 						break outerLoop;&lt;br /&gt;
 					}&lt;br /&gt;
 				}&lt;br /&gt;
 			}&lt;br /&gt;
 		&lt;br /&gt;
 		if (mazeFine) {&lt;br /&gt;
 			System.out.println(&amp;quot;What a fine maze you've created!&amp;quot;);&lt;br /&gt;
 		}&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 	/**&lt;br /&gt;
 	 * depthFirstSearch() does a depth-first traversal of the maze, marking each&lt;br /&gt;
 	 * visited cell.  Returns true if a cycle is found.&lt;br /&gt;
 	 *&lt;br /&gt;
 	 * DO NOT CHANGE THIS METHOD.  Your code is expected to work with our copy&lt;br /&gt;
 	 * of this method.&lt;br /&gt;
 	 */&lt;br /&gt;
 	protected boolean depthFirstSearch(int x, int y, int fromWhere,&lt;br /&gt;
 									   boolean[][] cellVisited) {&lt;br /&gt;
 		boolean cycleDetected = false;&lt;br /&gt;
 		cellVisited[x][y] = true;&lt;br /&gt;
 		&lt;br /&gt;
 		// Visit the cell to the right?&lt;br /&gt;
 		if ((fromWhere != FROMRIGHT) &amp;amp;&amp;amp; !verticalWall(x, y)) {&lt;br /&gt;
 			if (cellVisited[x + 1][y]) {&lt;br /&gt;
 				cycleDetected = true;&lt;br /&gt;
 			} else {&lt;br /&gt;
 				cycleDetected = depthFirstSearch(x + 1, y, FROMLEFT, cellVisited) ||&lt;br /&gt;
 				cycleDetected;&lt;br /&gt;
 			}&lt;br /&gt;
 		}&lt;br /&gt;
 		&lt;br /&gt;
 		// Visit the cell below?&lt;br /&gt;
 		if ((fromWhere != FROMBELOW) &amp;amp;&amp;amp; !horizontalWall(x, y)) {&lt;br /&gt;
 			if (cellVisited[x][y + 1]) {&lt;br /&gt;
 				cycleDetected = true;&lt;br /&gt;
 			} else {&lt;br /&gt;
 				cycleDetected = depthFirstSearch(x, y + 1, FROMABOVE, cellVisited) ||&lt;br /&gt;
 				cycleDetected;&lt;br /&gt;
 			}&lt;br /&gt;
 		}&lt;br /&gt;
 		&lt;br /&gt;
 		// Visit the cell to the left?&lt;br /&gt;
 		if ((fromWhere != FROMLEFT) &amp;amp;&amp;amp; !verticalWall(x - 1, y)) {&lt;br /&gt;
 			if (cellVisited[x - 1][y]) {&lt;br /&gt;
 				cycleDetected = true;&lt;br /&gt;
 			} else {&lt;br /&gt;
 				cycleDetected = depthFirstSearch(x - 1, y, FROMRIGHT, cellVisited) ||&lt;br /&gt;
 				cycleDetected;&lt;br /&gt;
 			}&lt;br /&gt;
 		}&lt;br /&gt;
 		&lt;br /&gt;
 		// Visit the cell above?&lt;br /&gt;
 		if ((fromWhere != FROMABOVE) &amp;amp;&amp;amp; !horizontalWall(x, y - 1)) {&lt;br /&gt;
 			if (cellVisited[x][y - 1]) {&lt;br /&gt;
 				cycleDetected = true;&lt;br /&gt;
 			} else {&lt;br /&gt;
 				cycleDetected = depthFirstSearch(x, y - 1, FROMBELOW, cellVisited) ||&lt;br /&gt;
 				cycleDetected;&lt;br /&gt;
 			}&lt;br /&gt;
 		}&lt;br /&gt;
 		&lt;br /&gt;
 		return cycleDetected;&lt;br /&gt;
 	}&lt;br /&gt;
 	&lt;br /&gt;
 	/**&lt;br /&gt;
 	 * main() creates a maze of dimensions specified on the command line, prints&lt;br /&gt;
 	 * the maze, and runs the diagnostic method to see if the maze is good.&lt;br /&gt;
 	 */&lt;br /&gt;
 	public static void main(String[] args) {&lt;br /&gt;
 		int x = 39;&lt;br /&gt;
 		int y = 15;&lt;br /&gt;
 		&lt;br /&gt;
 		/**&lt;br /&gt;
 		 *  Read the input parameters.&lt;br /&gt;
 		 */&lt;br /&gt;
 		&lt;br /&gt;
 		if (args.length &amp;gt; 0) {&lt;br /&gt;
 			try {&lt;br /&gt;
 				x = Integer.parseInt(args[0]);&lt;br /&gt;
 			}&lt;br /&gt;
 			catch (NumberFormatException e) {&lt;br /&gt;
 				System.out.println(&amp;quot;First argument to Simulation is not an number.&amp;quot;);&lt;br /&gt;
 			}&lt;br /&gt;
 		}&lt;br /&gt;
 		&lt;br /&gt;
 		if (args.length &amp;gt; 1) {&lt;br /&gt;
 			try {&lt;br /&gt;
 				y = Integer.parseInt(args[1]);&lt;br /&gt;
 			}&lt;br /&gt;
 			catch (NumberFormatException e) {&lt;br /&gt;
 				System.out.println(&amp;quot;Second argument to Simulation is not an number.&amp;quot;);&lt;br /&gt;
 			}&lt;br /&gt;
 		}&lt;br /&gt;
 		&lt;br /&gt;
 		Maze maze = new Maze(x, y);&lt;br /&gt;
 		System.out.print(maze);&lt;br /&gt;
 		maze.diagnose();&lt;br /&gt;
 	}&lt;br /&gt;
 }&lt;/div&gt;</summary>
		<author><name>Lensovet</name></author>
		
	</entry>
</feed>