Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

updated readme

  • Loading branch information...
commit 7235b04e57dfa03f7f17777278468d5d0cbaf66d 1 parent 46982f3
Weinan Li authored March 24, 2013
7  .idea/ant.xml
... ...
@@ -0,0 +1,7 @@
  1
+<?xml version="1.0" encoding="UTF-8"?>
  2
+<project version="4">
  3
+  <component name="AntConfiguration">
  4
+    <defaultAnt bundledAnt="true" />
  5
+  </component>
  6
+</project>
  7
+
13  .idea/libraries/Maven__junit_junit_4_10.xml
... ...
@@ -0,0 +1,13 @@
  1
+<component name="libraryTable">
  2
+  <library name="Maven: junit:junit:4.10">
  3
+    <CLASSES>
  4
+      <root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.10/junit-4.10.jar!/" />
  5
+    </CLASSES>
  6
+    <JAVADOC>
  7
+      <root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.10/junit-4.10-javadoc.jar!/" />
  8
+    </JAVADOC>
  9
+    <SOURCES>
  10
+      <root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.10/junit-4.10-sources.jar!/" />
  11
+    </SOURCES>
  12
+  </library>
  13
+</component>
13  .idea/libraries/Maven__org_hamcrest_hamcrest_core_1_1.xml
... ...
@@ -0,0 +1,13 @@
  1
+<component name="libraryTable">
  2
+  <library name="Maven: org.hamcrest:hamcrest-core:1.1">
  3
+    <CLASSES>
  4
+      <root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar!/" />
  5
+    </CLASSES>
  6
+    <JAVADOC>
  7
+      <root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1-javadoc.jar!/" />
  8
+    </JAVADOC>
  9
+    <SOURCES>
  10
+      <root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1-sources.jar!/" />
  11
+    </SOURCES>
  12
+  </library>
  13
+</component>
29  README.md
Source Rendered
... ...
@@ -1,4 +1,27 @@
1  
-mazejava
2  
-========
  1
+# Maze Java
  2
+
  3
+A maze game written in java for fun.
  4
+
  5
+## Usage
  6
+
  7
+Create a 5x5 maze:
  8
+
  9
+   Maze maze = MazeFactory.createMaze(5, 5);
  10
+
  11
+Print it:
  12
+
  13
+   maze.print();
  14
+
  15
+   	+---+---+---+---+---+
  16
+   	  >     |   |       |
  17
+   	+---+   +   +   +   +
  18
+   	|   |   |       |   |
  19
+   	+   +   +   +---+   +
  20
+   	|   |   |       |   |
  21
+   	+   +   +---+---+   +
  22
+   	|       |       |   |
  23
+   	+   +---+   +   +   +
  24
+   	|           |     V |
  25
+   	+---+---+---+---+   +
  26
+
3 27
 
4  
-MazeJava
38  pom.xml
... ...
@@ -1,25 +1,19 @@
1  
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2  
-  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3  
-  <modelVersion>4.0.0</modelVersion>
  1
+<?xml version="1.0" encoding="UTF-8"?>
  2
+<project xmlns="http://maven.apache.org/POM/4.0.0"
  3
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  5
+    <modelVersion>4.0.0</modelVersion>
4 6
 
5  
-  <groupId>io</groupId>
6  
-  <artifactId>maze</artifactId>
7  
-  <version>1.0-SNAPSHOT</version>
8  
-  <packaging>jar</packaging>
  7
+    <groupId>mazejava</groupId>
  8
+    <artifactId>mazejava</artifactId>
  9
+    <version>1.0-SNAPSHOT</version>
9 10
 
10  
-  <name>maze</name>
11  
-  <url>http://maven.apache.org</url>
  11
+    <dependencies>
12 12
 
13  
-  <properties>
14  
-    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15  
-  </properties>
16  
-
17  
-  <dependencies>
18  
-    <dependency>
19  
-      <groupId>junit</groupId>
20  
-      <artifactId>junit</artifactId>
21  
-      <version>3.8.1</version>
22  
-      <scope>test</scope>
23  
-    </dependency>
24  
-  </dependencies>
25  
-</project>
  13
+        <dependency>
  14
+            <groupId>junit</groupId>
  15
+            <artifactId>junit</artifactId>
  16
+            <version>4.10</version>
  17
+        </dependency>
  18
+    </dependencies>
  19
+</project>
18  src/main/java/io/maze/Maze.java
@@ -18,7 +18,7 @@
18 18
     private CellState in, out;
19 19
     private CellState[][] cells;
20 20
     private int m, n;
21  
-    private LinkedList<CellState> histories = new LinkedList<CellState>();
  21
+    private Stack<CellState> histories = new Stack<CellState>();
22 22
     private int visited_cnt = 0;
23 23
 
24 24
     public Maze(int m, int n) {
@@ -48,7 +48,7 @@ public void generate() {
48 48
         histories.push(currentCell);
49 49
         visited_cnt++;
50 50
 
51  
-        System.out.println("LEGEND: C- CANDIDATE, D- DECISION, R- RESULT, F- FALLBACK");
  51
+        System.out.println("LEGEND: C- CANDIDATE, D- DECISION, R- RESULT, G- GO BACK");
52 52
         while (histories.size() > 0 && visited_cnt < m*n) {
53 53
 
54 54
             while (currentCell != null) {
@@ -59,7 +59,7 @@ public void generate() {
59 59
                 }
60 60
             }
61 61
             currentCell = histories.pop();
62  
-            System.out.println("F- x:" + currentCell.getX() + " y:" + currentCell.getY());
  62
+            System.out.println("(G- x:" + currentCell.getX() + " y:" + currentCell.getY() + ")");
63 63
         }
64 64
     }
65 65
 
@@ -183,17 +183,27 @@ public void print() {
183 183
 
184 184
         for (int y = 0; y < n; y++) {
185 185
             Queue<String> parts = new LinkedList<String>();
186  
-
187 186
             for (int x = 0; x < m; x++) {
  187
+
188 188
                 CellState cell = cells[x][y];
189 189
                 String part = new String(token);
190 190
 
  191
+                if (x==0 && y==0) { // in
  192
+                    part = part.replaceAll("   \\|", " > |");
  193
+                }
  194
+
  195
+                if (x==m-1 && y==n-1) { //out
  196
+                    part = part.replaceAll("   \\|", " V |");
  197
+                }
  198
+
  199
+
191 200
                 if (cell.getSouthDoor().isOpened()) {
192 201
                     part = part.replaceAll("\\-", " ");
193 202
                 }
194 203
                 if (cell.getEastDoor().isOpened()) {
195 204
                     part = part.replaceAll("\\|", " ");
196 205
                 }
  206
+
197 207
                 parts.offer(part);
198 208
             }
199 209
 
2  src/main/java/io/maze/PlayMaze.java
@@ -13,7 +13,7 @@
13 13
 public class PlayMaze {
14 14
 
15 15
     public static final void main(String[] args) {
16  
-        Maze maze = MazeFactory.createMaze(60, 60);
  16
+        Maze maze = MazeFactory.createMaze(5, 5);
17 17
         maze.print();
18 18
     }
19 19
 }

0 notes on commit 7235b04

Please sign in to comment.
Something went wrong with that request. Please try again.