--- /dev/null
+/* =============================================================================
+ *
+ * coordinate.java
+ *
+ * =============================================================================
+ *
+ * Copyright (C) Stanford University, 2006. All Rights Reserved.
+ * Author: Chi Cao Minh
+ *
+ * =============================================================================
+ *
+ * For the license of bayes/sort.h and bayes/sort.c, please see the header
+ * of the files.
+ *
+ * ------------------------------------------------------------------------
+ *
+ * For the license of kmeans, please see kmeans/LICENSE.kmeans
+ *
+ * ------------------------------------------------------------------------
+ *
+ * For the license of ssca2, please see ssca2/COPYRIGHT
+ *
+ * ------------------------------------------------------------------------
+ *
+ * For the license of lib/mt19937ar.c and lib/mt19937ar.h, please see the
+ * header of the files.
+ *
+ * ------------------------------------------------------------------------
+ *
+ * For the license of lib/rbtree.h and lib/rbtree.c, please see
+ * lib/LEGALNOTICE.rbtree and lib/LICENSE.rbtree
+ *
+ * ------------------------------------------------------------------------
+ *
+ * Unless otherwise noted, the following license applies to STAMP files:
+ *
+ * Copyright (c) 2007, Stanford University
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Stanford University nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY STANFORD UNIVERSITY ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * =============================================================================
+ */
+
+
+
+
+import java.lang.Math;
+
+public class Coordinate {
+
+ public int x;
+ public int y;
+ public int z;
+
+ public Coordinate() {}
+
+
+ // coordiate_alloc will be constructor
+ // coordinate_t* coordinate_alloc(long x, long y, long z)
+ public Coordinate(int x,int y,int z) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ }
+
+ public static Coordinate alloc(int x,int y,int z) {
+ Coordinate c = new Coordinate(x,y,z);
+
+ return c;
+ }
+
+
+ // deallocate memory
+ // may not need
+ // coordinate_free
+
+ /*========================================================
+ // coordinate_isEqual
+ ==========================================================*/
+ public static boolean isEqual(Coordinate a,Coordinate b)
+ {
+ if((a.x == b.x) && (a.y == b.y) && (a.z == b.z))
+ return true;
+
+ return false;
+ }
+
+ /*==========================================================
+ *
+ * getPairDistance
+ *
+ *========================================================*/
+ private static double getPairDistance(Pair p)
+ {
+ Coordinate a = (Coordinate)p.first;
+ Coordinate b = (Coordinate)p.second;
+ int dx = a.x - b.x;
+ int dy = a.y - b.y;
+ int dz = a.z - b.z;
+ int dx2 = dx* dx;
+ int dy2 = dy* dy;
+ int dz2 = dz* dz;
+
+ return Math.sqrt((double)(dx2+dy2+dz2));
+ }
+
+
+ /*================================================
+ // coordinat_ comparePair
+ * -- For sorting in list of source/destination pairs
+ * -- Route longer paths first so they are more likely to suceed
+
+ *================================================*/
+ public static int comparePair(final Object a,final Object b)
+ {
+ double aDistance = getPairDistance((Pair)a);
+ double bDistance = getPairDistance((Pair)b);
+
+ if(aDistance < bDistance) {
+ return 1;
+ } else if(aDistance > bDistance) {
+ return -1;
+ }
+
+ return 0;
+ }
+
+ /*=======================================================
+ * coordinate_areAdjacent
+ *=======================================================*/
+
+ public static boolean areAdjacent(Coordinate a,Coordinate b)
+ {
+ int dx = a.x - b.x;
+ int dy = a.y - b.y;
+ int dz = a.z - b.z;
+ int dx2 = dx * dx;
+ int dy2 = dy * dy;
+ int dz2 = dz * dz;
+
+ return (((dx2 + dy2 + dz2) == 1) ? true : false);
+ }
+ }
+
+ /*=====================================================
+ *
+ * End of Coordinate
+ *
+ *====================================================*/
+
+
--- /dev/null
+/* =============================================================================
+ *
+ * grid.java
+ *
+ * =============================================================================
+ *
+ * Copyright (C) Stanford University, 2006. All Rights Reserved.
+ * Author: Chi Cao Minh
+ *
+ * =============================================================================
+ *
+ * For the license of bayes/sort.h and bayes/sort.c, please see the header
+ * of the files.
+ *
+ * ------------------------------------------------------------------------
+ *
+ * For the license of kmeans, please see kmeans/LICENSE.kmeans
+ *
+ * ------------------------------------------------------------------------
+ *
+ * For the license of ssca2, please see ssca2/COPYRIGHT
+ *
+ * ------------------------------------------------------------------------
+ *
+ * For the license of lib/mt19937ar.c and lib/mt19937ar.h, please see the
+ * header of the files.
+ *
+ * ------------------------------------------------------------------------
+ *
+ * For the license of lib/rbtree.h and lib/rbtree.c, please see
+ * lib/LEGALNOTICE.rbtree and lib/LICENSE.rbtree
+ *
+ * ------------------------------------------------------------------------
+ *
+ * Unless otherwise noted, the following license applies to STAMP files:
+ *
+ * Copyright (c) 2007, Stanford University
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Stanford University nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY STANFORD UNIVERSITY ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * =============================================================================
+ */
+
+import java.lang.Long;
+
+#define GRID_POINT_FULL -2
+#define GRID_POINT_EMPTY -1
+
+public class Grid {
+ public int width;
+ public int height;
+ public int depth;
+ public int[][][] points_unaligned;
+
+ public Grid() {}
+
+
+/* =============================================================================
+ * grid_alloc
+ * =============================================================================
+ grid_t* grid_alloc (long width, long height, long depth);
+
+ well... need to implement
+ got stuck
+*/
+ public static Grid alloc(int width,int height,int depth) {
+ Grid grid = new Grid();
+
+ if(grid != null) {
+ grid.width = width;
+ grid.height = height;
+ grid.depth = depth;
+
+ int[][][] points_unaligned = new int[width][height][depth];
+
+
+ for(int i=0;i<width;i++)
+ for(int j=0;j<height;j++)
+ for(int k=0;k<depth;k++)
+ points_unaligned[i][j][k]= GRID_POINT_EMPTY;
+
+ grid.points_unaligned = points_unaligned;
+ }
+
+ return grid;
+ }
+
+ public static Grid scratchalloc(int width,int height,int depth) {
+ Grid grid = scratch new Grid();
+ grid.width = width;
+ grid.height = height;
+ grid.depth = depth;
+ int[][][] points_unaligned = scratch new int[width][height][depth];
+ grid.points_unaligned = points_unaligned;
+ return grid;
+ }
+
+
+
+/* =============================================================================
+ * grid_copy
+ * =============================================================================
+ void grid_copy (grid_t* dstGridPtr, grid_t* srcGridPtr);
+ */
+ public static void copy(Grid dstGridPtr,Grid srcGridPtr) {
+ if((srcGridPtr.width == dstGridPtr.width) ||
+ (srcGridPtr.height == dstGridPtr.height) ||
+ (srcGridPtr.depth == dstGridPtr.depth)) {
+ int width=srcGridPtr.width;
+ int height=srcGridPtr.height;
+ int depth=srcGridPtr.depth;
+ System.deepArrayCopy(dstGridPtr.points_unaligned, srcGridPtr.points_unaligned);
+ }
+ }
+
+/* =============================================================================
+ * grid_isPointValid
+ * =============================================================================
+ bool_t grid_isPointValid (grid_t* gridPtr, long x, long y, long z);
+ */
+ public boolean isPointValid(int x,int y,int z) {
+ return x>=0 && x< width && y>=0 && y<height && z>=0 && z<depth;
+ }
+
+
+ public int getPoint(int x,int y,int z) {
+ return this.points_unaligned[x][y][z];
+ }
+
+
+/* =============================================================================
+ * grid_isPointEmpty
+ * =============================================================================
+ bool_t grid_isPointEmpty (grid_t* gridPtr, long x, long y, long z); {
+ */
+
+ public boolean isPointEmpty(int x,int y,int z) {
+ return points_unaligned[x][y][z]==GRID_POINT_EMPTY;
+ }
+
+
+
+/* =============================================================================
+ * grid_isPointFull
+ * =============================================================================
+ bool_t grid_isPointFull (grid_t* gridPtr, long x, long y, long z);
+ */
+ public boolean isPointFull(int x,int y,int z) {
+ return points_unaligned[x][y][z]==GRID_POINT_FULL;
+ }
+
+
+/* =============================================================================
+ * grid_setPoint
+ * =============================================================================
+ void grid_setPoint (grid_t* gridPtr, long x, long y, long z, long value);
+ */
+ public void setPoint(int x,int y,int z,int value) {
+ points_unaligned[x][y][z] = value;
+ }
+
+
+/* =============================================================================
+ * grid_addPath
+ * =============================================================================
+
+void grid_addPath (grid_t* gridPtr, vector_t* pointVectorPtr);
+*/
+ public void addPath(Vector_t pointVectorPtr) {
+ int i;
+ int n = pointVectorPtr.vector_getSize();
+
+ for(i = 0; i < n; i++) {
+ Coordinate coordinatePtr = (Coordinate)pointVectorPtr.vector_at(i);
+ int x = coordinatePtr.x;
+ int y = coordinatePtr.y;
+ int z = coordinatePtr.z;
+
+ points_unaligned[x][y][z]=GRID_POINT_FULL;
+ }
+ }
+
+ public boolean TM_addPath(Vector_t pointVectorPtr) {
+ int i;
+ int n = pointVectorPtr.vector_getSize();
+
+ int height = this.height;
+ int width = this.width;
+ int area = height * width;
+ for(i = 1; i < (n-1); i++) {
+ int gridPointIndex = ((Integer)(pointVectorPtr.vector_at(i))).intValue();
+ int z = gridPointIndex / area;
+ int index2d = gridPointIndex % area;
+ int y = index2d / width;
+ int x = index2d % width;
+ if (points_unaligned[x][y][z] != GRID_POINT_EMPTY) {
+ return true;
+ }
+ }
+
+ for(i = 1; i < (n-1); i++) {
+ int gridPointIndex = ((Integer)(pointVectorPtr.vector_at(i))).intValue();
+ int z = gridPointIndex / area;
+ int index2d = gridPointIndex % area;
+ int y = index2d / width;
+ int x = index2d % width;
+ points_unaligned[x][y][z] = GRID_POINT_FULL;
+ }
+ return false;
+ }
+
+ public int getPointIndex(int x,int y,int z) {
+ return ((z * height) + y) * width + x;
+ }
+
+
+
+}
+
+
+/* =============================================================================
+ *
+ * End of grid.c
+ *
+ * =============================================================================
+ */
--- /dev/null
+/* =============================================================================
+ *
+ * Labyrinth.java
+ *
+ * =============================================================================
+ *
+ * Copyright (C) Stanford University, 2006. All Rights Reserved.
+ * Author: Chi Cao Minh
+ *
+ * =============================================================================
+ *
+ * For the license of bayes/sort.h and bayes/sort.c, please see the header
+ * of the files.
+ *
+ * ------------------------------------------------------------------------
+ *
+ * For the license of kmeans, please see kmeans/LICENSE.kmeans
+ *
+ * ------------------------------------------------------------------------
+ *
+ * For the license of ssca2, please see ssca2/COPYRIGHT
+ *
+ * ------------------------------------------------------------------------
+ *
+ * For the license of lib/mt19937ar.c and lib/mt19937ar.h, please see the
+ * header of the files.
+ *
+ * ------------------------------------------------------------------------
+ *
+ * For the license of lib/rbtree.h and lib/rbtree.c, please see
+ * lib/LEGALNOTICE.rbtree and lib/LICENSE.rbtree
+ *
+ * ------------------------------------------------------------------------
+ *
+ * Unless otherwise noted, the following license applies to STAMP files:
+ *
+ * Copyright (c) 2007, Stanford University
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Stanford University nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY STANFORD UNIVERSITY ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * =============================================================================
+ */
+
+public class Labyrinth extends Thread{
+
+ static String global_inputFile;
+ static boolean global_doPrint;
+ int numThread;
+ int bendCost;
+ int xCost;
+ int yCost;
+ int zCost;
+
+
+ // For threads
+ int threadID;
+ Solve_Arg routerArg;
+
+ private void setDefaultParams() {
+
+ /* default values */
+ global_inputFile = null;
+ global_doPrint = false;
+ bendCost = 1;
+ xCost = 1;
+ yCost = 1;
+ zCost = 2;
+ numThread = 1;
+ }
+
+ private void parseArg(String[] argv) {
+ int i=0;
+ String arg;
+ boolean opterr = false;
+
+
+ setDefaultParams();
+
+ while (i < argv.length) {
+
+ if(argv[i].charAt(0) == '-' ) {
+ arg = argv[i++];
+ // check options
+ if(arg.equals("-b")) {
+ bendCost = Integer.parseInt(argv[i++]);
+ }
+ else if(arg.equals("-x")) {
+ xCost = Integer.parseInt(argv[i++]);
+ }
+ else if(arg.equals("-y")) {
+ yCost = Integer.parseInt(argv[i++]);
+ }
+ else if(arg.equals("-z")) {
+ zCost = Integer.parseInt(argv[i++]);
+ }
+ else if(arg.equals("-t")) {
+ numThread = Integer.parseInt(argv[i++]);
+ }
+ else if(arg.equals("-i")) {
+ global_inputFile = argv[i++];
+ }
+ else if(arg.equals("-p")) {
+ global_doPrint = true;
+ }
+ else {
+ System.out.println("Non-option argument: " + argv[i]);
+ opterr = true;
+ }
+
+ }
+ }
+ if(opterr) {
+ displayUsage();
+ System.exit(1);
+ }
+ }
+
+ public Labyrinth(String[] argv)
+ {
+ parseArg(argv);
+ }
+
+
+ public Labyrinth(int myID,Solve_Arg rArg)
+ {
+ threadID = myID;
+ routerArg = rArg;
+ }
+
+ public void run() {
+ Barrier.enterBarrier();
+ Router.solve(routerArg);
+ Barrier.enterBarrier();
+ }
+
+ public void displayUsage()
+ {
+ System.out.println("Usage: Labyrinth [options]");
+ System.out.println("Options:");
+ System.out.println(" b <INT> bend cost");
+ System.out.println(" i <FILE> input file name");
+ System.out.println(" p print routed maze");
+ System.out.println(" t <INT> Number of threads");
+ System.out.println(" x <INT> x movement cost");
+ System.out.println(" y <INT> y movement cost");
+ System.out.println(" z <INT> z movement cost");
+ }
+
+
+ public static void main(String[] argv)
+ {
+ /*
+ * Initailization
+ */
+
+ Labyrinth labyrinth = new Labyrinth(argv);
+
+ Barrier.setBarrier(labyrinth.numThread);
+
+ Maze mazePtr = Maze.alloc();
+
+ int numPathToRoute = mazePtr.readMaze(labyrinth.global_inputFile);
+
+ Router routerPtr = Router.alloc(labyrinth.xCost,labyrinth.yCost,
+ labyrinth.zCost,labyrinth.bendCost);
+
+ List_t pathVectorListPtr = List_t.alloc(0); // list_t.alloc(null)
+ /*
+ * Run transactions
+ */
+ Solve_Arg routerArg = new Solve_Arg(routerPtr,mazePtr,pathVectorListPtr);
+
+ /* Create and start thread */
+
+ Labyrinth[] lb = new Labyrinth[labyrinth.numThread];
+
+ for(int i = 1; i<labyrinth.numThread;i++) {
+ lb[i] = new Labyrinth(i,routerArg);
+ }
+
+ long start = System.currentTimeMillis();
+
+ for(int i = 1; i<labyrinth.numThread;i++) {
+ lb[i].start();
+ }
+
+ Barrier.enterBarrier();
+ Router.solve(routerArg);
+ Barrier.enterBarrier();
+
+ /* End of Solve */
+ long finish = System.currentTimeMillis();
+
+
+ int numPathRouted = 0;
+ List_Iter it = new List_Iter();
+
+ it.reset(pathVectorListPtr);
+ while(it.hasNext(pathVectorListPtr)) {
+ Vector_t pathVectorPtr = (Vector_t)it.next(pathVectorListPtr);
+ numPathRouted += pathVectorPtr.vector_getSize();
+ }
+
+ float elapsed = ((float)finish-(float)start)/1000;
+
+ System.out.println("Paths routed = " + numPathRouted);
+ System.out.println("Elapsed time = " + elapsed);
+
+ boolean stats = mazePtr.checkPaths(pathVectorListPtr,labyrinth.global_doPrint);
+ if(!stats)
+ {
+ System.out.println("Verification not passed");
+
+ }
+ else
+ System.out.println("Verification passed.");
+ System.out.println("Finished");
+ }
+}
+
+/* =============================================================================
+ *
+ * End of labyrinth.c
+ *
+ * =============================================================================
+ */
--- /dev/null
+public class List_Iter {
+ List_Node itPtr;
+
+ /* =============================================================================
+ * list_iter_reset
+ * =============================================================================
+ void list_iter_reset (list_iter_t* itPtr, list_t* listPtr);
+ */
+ public List_Iter() {
+ itPtr = null;
+ }
+
+ public void reset(List_t listPtr)
+ {
+ itPtr = listPtr.head;
+ }
+
+ /* =============================================================================
+ * list_iter_hasNext
+ * =============================================================================
+ * bool_t list_iter_hasNext (list_iter_t* itPtr, list_t* listPtr);
+ */
+ public boolean hasNext(List_t listPtr) {
+ return (itPtr.nextPtr != null)? true : false;
+ }
+
+ /* =============================================================================
+ * list_iter_next
+ * =============================================================================
+ * void* list_iter_next (list_iter_t* itPtr, list_t* listPtr);
+ */
+ public Object next(List_t listPtr)
+ {
+ itPtr = itPtr.nextPtr;
+ return itPtr.dataPtr;
+ }
+}
+
--- /dev/null
+
+public class List_Node {
+ Object dataPtr;
+ List_Node nextPtr;
+
+ public List_Node() {
+ dataPtr = null;
+ nextPtr = null;
+ }
+}
--- /dev/null
+/* =============================================================================
+ *
+ * List_t.java
+ * -- Sorted singly linked list
+ * -- Options: duplicate allowed
+ * (DLIST_NO_DUPLICATES) is no implemented yet (default: allow duplicates)
+ *
+ * =============================================================================
+ *
+ * Copyright (C) Stanford University, 2006. All Rights Reserved.
+ * Author: Chi Cao Minh
+ *
+ * =============================================================================
+ *
+ * For the license of bayes/sort.h and bayes/sort.c, please see the header
+ * of the files.
+ *
+ * ------------------------------------------------------------------------
+ *
+ * For the license of kmeans, please see kmeans/LICENSE.kmeans
+ *
+ * ------------------------------------------------------------------------
+ *
+ * For the license of ssca2, please see ssca2/COPYRIGHT
+ *
+ * ------------------------------------------------------------------------
+ *
+ * For the license of lib/mt19937ar.c and lib/mt19937ar.h, please see the
+ * header of the files.
+ *
+ * ------------------------------------------------------------------------
+ *
+ * For the license of lib/rbtree.h and lib/rbtree.c, please see
+ * lib/LEGALNOTICE.rbtree and lib/LICENSE.rbtree
+ *
+ * ------------------------------------------------------------------------
+ *
+ * Unless otherwise noted, the following license applies to STAMP files:
+ *
+ * Copyright (c) 2007, Stanford University
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Stanford University nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY STANFORD UNIVERSITY ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * =============================================================================
+ */
+
+
+public class List_t {
+
+ public List_Node head;
+ boolean isCoordinate;
+ int size;
+
+ public List_t() {
+ head = new List_Node();
+ }
+
+
+ /* =======================================================================
+ * allocNode
+ * -- Returns null on failure
+ * =======================================================================
+ */
+ private List_Node allocNode(Object dataPtr)
+ {
+ List_Node nodePtr = new List_Node();
+
+ if(nodePtr == null) {
+ return null;
+ }
+
+ nodePtr.dataPtr = dataPtr;
+ nodePtr.nextPtr = null;
+
+ return nodePtr;
+ }
+
+
+/* =============================================================================
+ * list_alloc
+ * -- If NULL passed for 'compare' function, will compare data pointer addresses
+ * -- Returns NULL on failure
+ * =============================================================================
+ * list_t* list_alloc (long (*compare)(const void*, const void*));
+ *
+ *
+ */
+
+ public static List_t alloc(int isCoordinate)
+ {
+ List_t listPtr = new List_t();
+
+ if(listPtr == null) {
+ return null;
+ }
+
+ listPtr.head.dataPtr = null;
+ listPtr.head.nextPtr = null;
+ listPtr.size = 0;
+
+ listPtr.isCoordinate = (isCoordinate==1)?true:false;
+
+ return listPtr;
+ }
+
+/* =============================================================================
+ * list_free
+ * -- If NULL passed for 'compare' function, will compare data pointer addresses
+ * -- Returns NULL on failure
+ * =============================================================================
+ * void list_free (list_t* listPtr);
+ */
+ public static void free(List_t listPtr)
+ {
+ listPtr = null;
+ }
+
+// privae freeList
+
+/* =============================================================================
+ * list_isEmpty
+ * -- Return TRUE if list is empty, else FALSE
+ * =============================================================================
+ * bool_t list_isEmpty (list_t* listPtr);
+ */
+ public boolean isEmpty()
+ {
+ return (head.nextPtr == null);
+ }
+
+/* =============================================================================
+ * list_getSize
+ * -- Returns size of list
+ * =============================================================================
+ * long list_getSize (list_t* listPtr);
+ */
+ public int getSize() {
+ return size;
+ }
+
+/* =============================================================================
+ * findPrevious
+ * =============================================================================
+ * void* list_find (list_t* listPtr, void* dataPtr);
+ */
+ private List_Node findPrevious(Object dataPtr)
+ {
+ List_Node prevPtr = head;
+ List_Node nodePtr = prevPtr.nextPtr;
+
+ for(; nodePtr != null; nodePtr = nodePtr.nextPtr) {
+ if (compare(nodePtr.dataPtr,dataPtr) >= 0) {
+ return prevPtr;
+ }
+ prevPtr = nodePtr;
+ }
+
+ return prevPtr;
+ }
+
+ /* =============================================================================
+ * list_find
+ * -- Returns NULL if not found, else returns pointer to data
+ * =============================================================================
+ * void* list_find (list_t* listPtr, void* dataPtr);
+ */
+ public Object find(Object dataPtr) {
+ List_Node nodePtr;
+ List_Node prevPtr = findPrevious(dataPtr);
+
+ nodePtr = prevPtr.nextPtr;
+
+ if((nodePtr == null) ||
+ (compare(nodePtr.dataPtr,dataPtr) != 0)) {
+ return null;
+ }
+
+ return (nodePtr.dataPtr);
+ }
+
+ public int compare(Object obj1,Object obj2)
+ {
+ if(isCoordinate)
+ {
+ return Coordinate.comparePair(obj1,obj2);
+ }
+ else
+ return compareObject(obj1,obj2);
+ }
+
+/* =============================================================================
+ * list_insert
+ * -- Return TRUE on success, else FALSE
+ * =============================================================================
+ * bool_t list_insert (list_t* listPtr, void* dataPtr);
+ */
+ public boolean insert(Object dataPtr) {
+ List_Node prevPtr;
+ List_Node nodePtr;
+ List_Node currPtr;
+
+ prevPtr = findPrevious(dataPtr);
+ currPtr = prevPtr.nextPtr;
+
+ nodePtr = allocNode(dataPtr);
+ if (nodePtr == null) {
+ return false;
+ }
+
+ nodePtr.nextPtr = currPtr;
+ prevPtr.nextPtr = nodePtr;
+ size++;
+
+ return true;
+ }
+
+
+/* =============================================================================
+ * list_remove
+ * -- Returns TRUE if successful, else FALSE
+ * =============================================================================
+ * bool_t list_remove (list_t* listPtr, void* dataPtr);
+ */
+ public boolean remove(Object dataPtr)
+ {
+ List_Node prevPtr;
+ List_Node nodePtr;
+
+ prevPtr = findPrevious(dataPtr);
+
+ nodePtr = prevPtr.nextPtr;
+
+ if((nodePtr != null) &&
+ (compare(nodePtr.dataPtr,dataPtr) == 0))
+ {
+ prevPtr.nextPtr = nodePtr.nextPtr;
+ nodePtr.nextPtr = null;
+ nodePtr = null;
+ size--;
+
+ return true;
+ }
+
+ return false;
+ }
+
+ int compareObject(Object obj1,Object obj2) {
+ return 1;
+ }
+
+
+/* =============================================================================
+ * list_clear
+ * -- Removes all elements
+ * =============================================================================
+ * void list_clear (list_t* listPtr);
+ */
+ public void clear() {
+ head = new List_Node();
+ size = 0;
+ }
+
+/* =============================================================================
+ *
+ * End of list.java
+ *
+ * =============================================================================
+ */
+
+ /* Test list */
+
+ public static void main(String[] argv) {
+ List_t listPtr;
+ int[] data1 = new int[5];
+ int[] data2 = new int[6];
+
+ int i;
+
+ System.out.println("Starting...");
+ }
+
+}
+
+
+
--- /dev/null
+/*=============================================================================
+ *
+ * Maze.java
+ *
+ * =============================================================================
+ *
+ * Copyright (C) Stanford University, 2006. All Rights Reserved.
+ * Author: Chi Cao Minh
+ *
+ * =============================================================================
+ *
+ * For the license of bayes/sort.h and bayes/sort.c, please see the header
+ * of the files.
+ *
+ * ------------------------------------------------------------------------
+ *
+ * For the license of kmeans, please see kmeans/LICENSE.kmeans
+ *
+ * ------------------------------------------------------------------------
+ *
+ * For the license of ssca2, please see ssca2/COPYRIGHT
+ *
+ * ------------------------------------------------------------------------
+ *
+ * For the license of lib/mt19937ar.c and lib/mt19937ar.h, please see the
+ * header of the files.
+ *
+ * ------------------------------------------------------------------------
+ *
+ * For the license of lib/rbtree.h and lib/rbtree.c, please see
+ * lib/LEGALNOTICE.rbtree and lib/LICENSE.rbtree
+ *
+ * ------------------------------------------------------------------------
+ *
+ * Unless otherwise noted, the following license applies to STAMP files:
+ *
+ * Copyright (c) 2007, Stanford University
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Stanford University nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY STANFORD UNIVERSITY ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * =============================================================================
+ */
+
+#define GRID_POINT_FULL -2
+#define GRID_POINT_EMPTY -1
+
+public class Maze {
+ Grid gridPtr;
+ Queue_t workQueuePtr;
+ Vector_t wallVectorPtr; /* contains source/destination pairs to route */
+ Vector_t srcVectorPtr; /* obstacles */
+ Vector_t dstVectorPtr; /* destinations */
+
+ public Maze() {}
+
+
+/* =============================================================================
+ * maze_alloc
+ * =============================================================================
+ maze_t* maze_alloc ();
+ */
+ public static Maze alloc()
+ {
+ Maze mazePtr = new Maze();
+
+ if(mazePtr != null) {
+ mazePtr.gridPtr = null;
+ mazePtr.workQueuePtr = Queue_t.queue_alloc(1024);
+ mazePtr.wallVectorPtr = Vector_t.vector_alloc(1);
+ mazePtr.srcVectorPtr = Vector_t.vector_alloc(1);
+ mazePtr.dstVectorPtr = Vector_t.vector_alloc(1);
+
+ }
+
+ return mazePtr;
+ }
+
+/* =============================================================================
+ * maze_free
+ * =============================================================================
+ void maze_free (maze_t* mazePtr);
+ */
+ public static void free(Maze m)
+ {
+ m = null;
+ }
+
+/* =============================================================================
+ * addToGrid
+ * =============================================================================
+ */
+ private void addToGrid(Grid gridPtr,Vector_t vectorPtr,String type)
+ {
+ int i;
+ int n = vectorPtr.vector_getSize();
+
+ for(i = 0; i < n; i++) {
+ Coordinate coordinatePtr = (Coordinate)vectorPtr.vector_at(i);
+ if(!gridPtr.isPointValid(coordinatePtr.x,coordinatePtr.y,coordinatePtr.z))
+ {
+ System.out.println("Error: " + type + " (" + coordinatePtr.x +
+ ", " + coordinatePtr.y +
+ ", " + coordinatePtr.z);
+ System.exit(1);
+ }
+ }
+ gridPtr.addPath(vectorPtr);
+ }
+/* =============================================================================
+ * maze_read
+ * -- Return number of path to route
+ * =============================================================================
+ long maze_read (maze_t* mazePtr, char* inputFileName);
+ */
+ public int readMaze(String inputFileName)
+ {
+ FileInputStream in = new FileInputStream(inputFileName);
+ /*
+ * Parse input file
+ */
+ int lineNumber = 0;
+ int height = -1;
+ int width = -1;
+ int depth = -1;
+ boolean isParseError = false;
+ List_t workListPtr = List_t.alloc(1); // List.alloc(Coordinate.comparePair);
+ String line;
+
+ while((line = in.readLine()) != null) {
+
+ String code;
+ int[] xy = new int[6]; // equivalent to x1,y1,z1,x2,y2,z2
+ int numToken = 0;
+
+ StringTokenizer tok = new StringTokenizer(line);
+
+ if((numToken = tok.countTokens()) < 1 ) {
+ continue;
+ }
+
+ code = tok.nextToken();
+
+ if(code.equals("#")) {
+ /* comment line */
+ continue;
+ }
+ for(int i=0;i<numToken-1;i++) {
+ xy[i] = Integer.parseInt(tok.nextToken());
+ }
+
+ if(code.equals("d")) {
+ /* dimensions (format: d x y z) */
+ if(numToken != 4) {
+ isParseError = true;
+ }
+ else {
+ width = xy[0];
+ height = xy[1];
+ depth = xy[2];
+ if(width < 1 || height < 1 || depth <1)
+ isParseError = true;
+ }
+ }else if(code.equals("p")) { /* paths (format: p x1 y1 z1 x2 y2 z2) */
+ if(numToken != 7) {
+ isParseError = true;
+ }
+ else {
+ Coordinate srcPtr = Coordinate.alloc(xy[0],xy[1],xy[2]);
+ Coordinate dstPtr = Coordinate.alloc(xy[3],xy[4],xy[5]);
+
+ if(Coordinate.isEqual(srcPtr,dstPtr)) {
+ isParseError = true;
+ }
+ else {
+ Pair coordinatePairPtr = Pair.alloc(srcPtr,dstPtr);
+ boolean status = workListPtr.insert(coordinatePairPtr);
+ if(!status) {
+ System.out.println("LIST_INSERT????");
+ System.exit(1);
+ }
+ srcVectorPtr.vector_pushBack(srcPtr);
+ dstVectorPtr.vector_pushBack(dstPtr);
+
+ }
+ }
+ }else if(code.equals("w")) {
+ /* walls (format: w x y z) */
+ if(numToken != 4) {
+ isParseError = true;
+ } else {
+ Coordinate wallPtr = Coordinate.alloc(xy[0],xy[1],xy[2]);
+ wallVectorPtr.vector_pushBack(wallPtr);
+ }
+ }else { /* error */
+ isParseError = true;
+ }
+
+ if(isParseError) {/* Error */
+ System.out.println("Error: line " + lineNumber + " of " + inputFileName + "invalid");
+ System.exit(1);
+ }
+ }
+ /* iterate over lines in put file */
+
+ in.close();
+ /*
+ * Initialize grid contents
+ */
+ if(width < 1 || height < 1 || depth < 1) {
+ System.out.println("Error : Invalid dimensions ( " + width + ", " + height + ", "+ depth + ")");
+ System.exit(1);
+ }
+
+ Grid gridPtr = Grid.alloc(width,height,depth);
+ this.gridPtr = gridPtr;
+ addToGrid(gridPtr,wallVectorPtr,"wall");
+ addToGrid(gridPtr,srcVectorPtr, "source");
+ addToGrid(gridPtr,dstVectorPtr, "destination");
+ System.out.println("Maze dimensions = " + width + " x " + height + " x " + depth);
+ System.out.println("Paths to route = " + workListPtr.getSize());
+
+ /*
+ * Initialize work queue
+ */
+ List_Iter it = new List_Iter();
+ it.reset(workListPtr);
+ while(it.hasNext(workListPtr)) {
+ Pair coordinatePairPtr = (Pair)it.next(workListPtr);
+ workQueuePtr.queue_push(coordinatePairPtr);
+ }
+
+ List_t.free(workListPtr);
+
+ return srcVectorPtr.vector_getSize();
+ }
+
+
+/* =============================================================================
+ * maze_checkPaths
+ * =============================================================================
+ bool_t maze_checkPaths (maze_t* mazePtr, list_t* pathListPtr, bool_t doPrintPaths);
+ */
+ public boolean checkPaths(List_t pathVectorListPtr,boolean doPrintPaths)
+ {
+ int i;
+
+ /* Mark walls */
+ Grid testGridPtr = Grid.alloc(gridPtr.width,gridPtr.height,gridPtr.depth);
+ testGridPtr.addPath(wallVectorPtr);
+
+ /* Mark sources */
+ int numSrc = srcVectorPtr.vector_getSize();
+// System.out.println("numSrc = " +numSrc);
+// System.exit(1);
+ for(i = 0; i < numSrc; i++) {
+ Coordinate srcPtr = (Coordinate)srcVectorPtr.vector_at(i);
+ testGridPtr.setPoint(srcPtr.x,srcPtr.y,srcPtr.z,0);
+ }
+
+ /* Mark destinations */
+ int numdst = dstVectorPtr.vector_getSize();
+ for(i = 0; i < numdst; i++) {
+ Coordinate dstPtr = (Coordinate)dstVectorPtr.vector_at(i);
+ testGridPtr.setPoint(dstPtr.x,dstPtr.y,dstPtr.z,0);
+ }
+
+// testGridPtr.print();
+
+ /* Make sure path is contiguous and does not overlap */
+ int id = 0;
+ List_Iter it = new List_Iter();
+ it.reset(pathVectorListPtr);
+
+ int height = gridPtr.height;
+ int width = gridPtr.width;
+ int area = height * width;
+
+ while(it.hasNext(pathVectorListPtr)) {
+ Vector_t pathVectorPtr = (Vector_t)it.next(pathVectorListPtr);
+ int numPath = pathVectorPtr.vector_getSize();
+
+ for(i = 0; i < numPath; i++) {
+ id++;
+ Vector_t pointVectorPtr = (Vector_t)pathVectorPtr.vector_at(i);
+ /* Check start */
+ int prevGridPointIndex = ((Integer)pointVectorPtr.vector_at(0)).intValue();
+
+ int z=prevGridPointIndex/area;
+ int index2d=prevGridPointIndex%area;
+ int y=index2d/width;
+ int x=index2d%width;
+
+ if(testGridPtr.getPoint(x,y,z) != 0) {
+ return false;
+ }
+
+ Coordinate prevCoordinate = new Coordinate();
+ prevCoordinate.x = x;
+ prevCoordinate.y = y;
+ prevCoordinate.z = z;
+
+
+ int numPoint = pointVectorPtr.vector_getSize();
+ int j;
+
+ for(j = 1; j< (numPoint - 1) ;j++) { /* no need to check endpoints */
+ int currGridPointIndex = ((Integer)pointVectorPtr.vector_at(j)).intValue();
+ Coordinate currCoordinate = new Coordinate();
+
+ z=currGridPointIndex/area;
+ index2d=currGridPointIndex%area;
+ y=index2d/width;
+ x=index2d%width;
+
+ currCoordinate.x = x;
+ currCoordinate.y = y;
+ currCoordinate.z = z;
+
+ if(!Coordinate.areAdjacent(currCoordinate,prevCoordinate)) {
+ System.out.println("you there?");
+ return false;
+ }
+
+ prevCoordinate = currCoordinate;
+ int xx = currCoordinate.x;
+ int yy = currCoordinate.y;
+ int zz = currCoordinate.z;
+ if(testGridPtr.getPoint(xx,yy,zz) != GRID_POINT_EMPTY) {
+ return false;
+ } else {
+ testGridPtr.setPoint(xx,yy,zz,id);
+ }
+ }
+ /* Check end */
+ int lastGridPointIndex = ((Integer)pointVectorPtr.vector_at(j)).intValue();
+ z=lastGridPointIndex/area;
+ index2d=lastGridPointIndex%area;
+ y=index2d/width;
+ x=index2d%width;
+ if(testGridPtr.getPoint(x,y,z) != 0) {
+ return false;
+ }
+ } /* iterate over pathVector */
+ } /* iterate over pathVectorList */
+
+ if(doPrintPaths) {
+ System.out.println("\nRouted Maze:");
+ // testGridPtr.print();
+ }
+
+
+ return true;
+ }
+
+ }
+/* =============================================================================
+ *
+ * End of maze.h
+ *
+ * =============================================================================
+ */
--- /dev/null
+
+ public class Point {
+ int x;
+ int y;
+ int z;
+ int value;
+ int momentum;
+
+ public Point() {
+ x = -1;
+ y = -1;
+ z = -1;
+ value = -1;
+ momentum = -1;
+ }
+
+ public Point(int x,int y, int z,int value, int m) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ this.value = value;
+ momentum = m;
+ }
+ }
+
--- /dev/null
+/* =============================================================================
+ *
+ * queue.java
+ *
+ * =============================================================================
+ *
+ * Copyright (C) Stanford University, 2006. All Rights Reserved.
+ * Author: Chi Cao Minh
+ *
+ * Ported to Java June 2009 Alokika Dash
+ * adash@uci.edu
+ * University of California, Irvine
+ *
+ * =============================================================================
+ *
+ * Unless otherwise noted, the following license applies to STAMP files:
+ *
+ * Copyright (c) 2007, Stanford University
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Stanford University nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY STANFORD UNIVERSITY ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * =============================================================================
+ */
+
+#define QUEUE_GROWTH_FACTOR 2
+
+public class Queue_Int {
+ int pop; /* points before element to pop */
+ int push;
+ int capacity;
+ int[] elements;
+
+ public Queue_Int() {
+ }
+
+ /* =============================================================================
+ * queue_alloc
+ * =============================================================================
+ */
+ public static Queue_Int queue_alloc (int initCapacity)
+ {
+ Queue_Int queuePtr = new Queue_Int();
+
+ int capacity = ((initCapacity < 2) ? 2 : initCapacity);
+ queuePtr.elements = new int[capacity];
+ if (queuePtr.elements == null) {
+ queuePtr = null;
+ return null;
+ }
+ queuePtr.pop = capacity - 1;
+ queuePtr.push = 0;
+ queuePtr.capacity = capacity;
+
+ return queuePtr;
+ }
+
+
+ /* =============================================================================
+ * Pqueue_alloc
+ * =============================================================================
+ */
+ public Queue_Int
+ Pqueue_alloc (int initCapacity)
+ {
+ Queue_Int queuePtr = new Queue_Int();
+
+ int capacity = ((initCapacity < 2) ? 2 : initCapacity);
+ queuePtr.elements = new int[capacity];
+ if (queuePtr.elements == null) {
+ queuePtr = null;
+ return null;
+ }
+ queuePtr.pop = capacity - 1;
+ queuePtr.push = 0;
+ queuePtr.capacity = capacity;
+
+ return queuePtr;
+ }
+
+
+ /* =============================================================================
+ * TMqueue_alloc
+ * =============================================================================
+ */
+ public Queue_Int TMqueue_alloc (int initCapacity)
+ {
+ Queue_Int queuePtr = new Queue_Int();
+
+ int capacity = ((initCapacity < 2) ? 2 : initCapacity);
+ queuePtr.elements = new int[capacity];
+ if (queuePtr.elements == null) {
+ queuePtr = null;
+ return null;
+ }
+ queuePtr.pop = capacity - 1;
+ queuePtr.push = 0;
+ queuePtr.capacity = capacity;
+
+ return queuePtr;
+ }
+
+
+ /* =============================================================================
+ * queue_free
+ * =============================================================================
+ */
+ public void
+ queue_free ()
+ {
+ elements = null;
+ }
+
+
+ /* =============================================================================
+ * Pqueue_free
+ * =============================================================================
+ */
+ public void
+ Pqueue_free ()
+ {
+ elements = null;
+ }
+
+
+ /* =============================================================================
+ * TMqueue_free
+ * =============================================================================
+ */
+ public void
+ TMqueue_free ()
+ {
+ elements = null;
+ }
+
+
+ /* =============================================================================
+ * queue_isEmpty
+ * =============================================================================
+ */
+ public boolean
+ queue_isEmpty ()
+ {
+ return (((pop + 1) % capacity == push) ? true : false);
+ }
+
+
+ /* =============================================================================
+ * queue_clear
+ * =============================================================================
+ */
+ public void
+ queue_clear ()
+ {
+ pop = capacity - 1;
+ push = 0;
+ }
+
+
+ /* =============================================================================
+ * TMqueue_isEmpty
+ * =============================================================================
+ */
+ public boolean
+ TMqueue_isEmpty (Queue_Int queuePtr)
+ {
+ int pop = queuePtr.pop;
+ int push = queuePtr.push;
+ int capacity = queuePtr.capacity;
+
+ return (((pop + 1) % capacity == push) ? true : false);
+ }
+
+
+ /* =============================================================================
+ * queue_push
+ * =============================================================================
+ */
+ public boolean
+ queue_push (int dataPtr)
+ {
+ if(pop == push) {
+ System.out.println("push == pop in Queue.java");
+ return false;
+ }
+
+ /* Need to resize */
+ int newPush = (push + 1) % capacity;
+ if (newPush == pop) {
+
+ int newCapacity = capacity * QUEUE_GROWTH_FACTOR;
+ int[] newElements = new int[newCapacity];
+ if (newElements == null) {
+ return false;
+ }
+
+ int dst = 0;
+ int[] tmpelements = elements;
+ if (pop < push) {
+ int src;
+ for (src = (pop + 1); src < push; src++, dst++) {
+ newElements[dst] = elements[src];
+ }
+ } else {
+ int src;
+ for (src = (pop + 1); src < capacity; src++, dst++) {
+ newElements[dst] = elements[src];
+ }
+ for (src = 0; src < push; src++, dst++) {
+ newElements[dst] = elements[src];
+ }
+ }
+
+ elements = newElements;
+ pop = newCapacity - 1;
+ capacity = newCapacity;
+ push = dst;
+ newPush = push + 1; /* no need modulo */
+ }
+
+ elements[push] = dataPtr;
+ push = newPush;
+
+ return true;
+ }
+
+
+ /* =============================================================================
+ * Pqueue_push
+ * =============================================================================
+ */
+ public boolean
+ Pqueue_push (Queue_Int queuePtr, int dataPtr)
+ {
+ int pop = queuePtr.pop;
+ int push = queuePtr.push;
+ int capacity = queuePtr.capacity;
+
+ if(pop == push) {
+ System.out.println("push == pop in Queue.java");
+ return false;
+ }
+
+ /* Need to resize */
+ int newPush = (push + 1) % capacity;
+ if (newPush == pop) {
+
+ int newCapacity = capacity * QUEUE_GROWTH_FACTOR;
+ int[] newElements = new int[newCapacity];
+ if (newElements == null) {
+ return false;
+ }
+
+ int dst = 0;
+ int[] elements = queuePtr.elements;
+ if (pop < push) {
+ int src;
+ for (src = (pop + 1); src < push; src++, dst++) {
+ newElements[dst] = elements[src];
+ }
+ } else {
+ int src;
+ for (src = (pop + 1); src < capacity; src++, dst++) {
+ newElements[dst] = elements[src];
+ }
+ for (src = 0; src < push; src++, dst++) {
+ newElements[dst] = elements[src];
+ }
+ }
+
+ elements = null;
+ queuePtr.elements = newElements;
+ queuePtr.pop = newCapacity - 1;
+ queuePtr.capacity = newCapacity;
+ push = dst;
+ newPush = push + 1; /* no need modulo */
+
+ }
+
+ queuePtr.elements[push] = dataPtr;
+ queuePtr.push = newPush;
+
+ return true;
+ }
+
+
+ /* =============================================================================
+ * TMqueue_push
+ * =============================================================================
+ */
+ public boolean
+ TMqueue_push (Queue_Int queuePtr, int dataPtr)
+ {
+ int pop = (queuePtr.pop);
+ int push = (queuePtr.push);
+ int capacity = (queuePtr.capacity);
+
+ if(pop == push) {
+ System.out.println("push == pop in Queue.java");
+ return false;
+ }
+
+ /* Need to resize */
+ int newPush = (push + 1) % capacity;
+ if (newPush == pop) {
+ int newCapacity = capacity * QUEUE_GROWTH_FACTOR;
+ int[] newElements = new int[newCapacity];
+ if (newElements == null) {
+ return false;
+ }
+
+ int dst = 0;
+ int[] elements = queuePtr.elements;
+ if (pop < push) {
+ int src;
+ for (src = (pop + 1); src < push; src++, dst++) {
+ newElements[dst] = (elements[src]);
+ }
+ } else {
+ int src;
+ for (src = (pop + 1); src < capacity; src++, dst++) {
+ newElements[dst] = (elements[src]);
+ }
+ for (src = 0; src < push; src++, dst++) {
+ newElements[dst] = (elements[src]);
+ }
+ }
+
+ elements = null;
+ queuePtr.elements = newElements;
+ queuePtr.pop = newCapacity - 1;
+ queuePtr.capacity = newCapacity;
+ push = dst;
+ newPush = push + 1; /* no need modulo */
+
+ }
+
+ int[] elements = queuePtr.elements;
+ elements[push] = dataPtr;
+ queuePtr.push = newPush;
+
+ return true;
+ }
+
+
+ /* =============================================================================
+ * queue_pop
+ * =============================================================================
+ */
+ public int
+ queue_pop ()
+ {
+ int newPop = (pop + 1) % capacity;
+ if (newPop == push) {
+ return 0;
+ }
+
+ int dataPtr = elements[newPop];
+ pop = newPop;
+
+ return dataPtr;
+ }
+
+
+ /* =============================================================================
+ * TMqueue_pop
+ * =============================================================================
+ */
+ public int
+ TMqueue_pop (Queue_Int queuePtr)
+ {
+ int pop = queuePtr.pop;
+ int push = queuePtr.push;
+ int capacity = queuePtr.capacity;
+
+ int newPop = (pop + 1) % capacity;
+ if (newPop == push) {
+ return 0;
+ }
+
+ int[] elements = queuePtr.elements;
+ int dataPtr = elements[newPop];
+ queuePtr.pop = newPop;
+
+ return dataPtr;
+ }
+
+ /****
+ * main method for testing
+ **/
+ /*
+ public static void main(String[] args) {
+ testQueue queuePtr = testQueue.queue_alloc(-1);
+ int numData = 4;
+ if(queuePtr.queue_isEmpty())
+ System.out.println("Queue is empty");
+
+ for(int i = 0; i<numData; i++) {
+ System.out.println("Inserting " + i);
+ queuePtr.queue_push(i);
+ }
+
+ for(int i = 0; i<numData; i++) {
+ int val = queuePtr.queue_pop();
+ System.out.println("Removing " + val);
+ }
+
+ if(queuePtr.queue_isEmpty())
+ System.out.println("Queue is empty");
+ }
+ */
+}
+/* =============================================================================
+ *
+ * End of queue.java
+ *
+ * =============================================================================
+ */
--- /dev/null
+/* =============================================================================
+ *
+ * queue.java
+ *
+ * =============================================================================
+ *
+ * Copyright (C) Stanford University, 2006. All Rights Reserved.
+ * Author: Chi Cao Minh
+ *
+ * Ported to Java
+ * Author:Alokika Dash
+ * University of California, Irvine
+ *
+ * =============================================================================
+ *
+ * Unless otherwise noted, the following license applies to STAMP files:
+ *
+ * Copyright (c) 2007, Stanford University
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Stanford University nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY STANFORD UNIVERSITY ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * =============================================================================
+ */
+
+#define QUEUE_GROWTH_FACTOR 2
+
+public class Queue_t {
+ int pop; /* points before element to pop */
+ int push;
+ int capacity;
+ Object[] elements;
+
+ public Queue_t() {
+ }
+
+ /* =============================================================================
+ * queue_alloc
+ * =============================================================================
+ */
+ public static Queue_t queue_alloc (int initCapacity)
+ {
+ Queue_t queuePtr = new Queue_t();
+
+ int capacity = ((initCapacity < 2) ? 2 : initCapacity);
+ queuePtr.elements = new Object[capacity];
+ if (queuePtr.elements == null) {
+ queuePtr = null;
+ return null;
+ }
+ queuePtr.pop = capacity - 1;
+ queuePtr.push = 0;
+ queuePtr.capacity = capacity;
+
+ return queuePtr;
+ }
+
+
+ /* =============================================================================
+ * Pqueue_alloc
+ * =============================================================================
+ */
+ public Queue_t
+ Pqueue_alloc (int initCapacity)
+ {
+ Queue_t queuePtr = new Queue_t();
+
+ int capacity = ((initCapacity < 2) ? 2 : initCapacity);
+ queuePtr.elements = new Object[capacity];
+ if (queuePtr.elements == null) {
+ queuePtr = null;
+ return null;
+ }
+ queuePtr.pop = capacity - 1;
+ queuePtr.push = 0;
+ queuePtr.capacity = capacity;
+
+ return queuePtr;
+ }
+
+ /* =============================================================================
+ * queue_free
+ * =============================================================================
+ */
+ public void
+ queue_free (Queue_t queuePtr)
+ {
+ queuePtr.elements = null;
+ queuePtr = null;
+ }
+
+
+ /* =============================================================================
+ * Pqueue_free
+ * =============================================================================
+ */
+ public void
+ Pqueue_free (Queue_t queuePtr)
+ {
+ queuePtr.elements = null;
+ queuePtr = null;
+ }
+
+
+ /* =============================================================================
+ * TMqueue_free
+ * =============================================================================
+ *
+ public void
+ TMqueue_free (TM_ARGDECL Queue* queuePtr)
+ {
+ queuePtr.elements = null;
+ queuePtr = null;
+ }
+
+*/
+ /* =============================================================================
+ * queue_isEmpty
+ * =============================================================================
+ */
+ public boolean
+ queue_isEmpty ()
+ {
+ //int pop = queuePtr.pop;
+ //int push = queuePtr.push;
+ //int capacity = queuePtr.capacity;
+
+ return (((pop + 1) % capacity == push) ? true : false);
+ }
+
+
+ /* =============================================================================
+ * queue_clear
+ * =============================================================================
+ */
+ public void
+ queue_clear ()
+ {
+ pop = capacity - 1;
+ push = 0;
+ }
+
+
+ /* =============================================================================
+ * TMqueue_isEmpty
+ * =============================================================================
+ */
+
+
+
+ /* =============================================================================
+ * queue_push
+ * =============================================================================
+ */
+ public boolean
+ queue_push (Object dataPtr)
+ {
+
+ if(pop == push) {
+
+ System.out.println("push == pop in Queue.java");
+ return false;
+ }
+
+
+ /* Need to resize */
+ int newPush = (push + 1) % capacity;
+ if (newPush == pop) {
+
+ int newCapacity = capacity * QUEUE_GROWTH_FACTOR;
+ Object[] newElements = new Object[newCapacity];
+ if (newElements == null) {
+ return false;
+ }
+
+ int dst = 0;
+ Object[] tmpelements = elements;
+ if (pop < push) {
+ int src;
+ for (src = (pop + 1); src < push; src++, dst++) {
+ newElements[dst] = elements[src];
+ }
+ } else {
+ int src;
+ for (src = (pop + 1); src < capacity; src++, dst++) {
+ newElements[dst] = elements[src];
+ }
+ for (src = 0; src < push; src++, dst++) {
+ newElements[dst] = elements[src];
+ }
+ }
+
+ //elements = null;
+ elements = newElements;
+ pop = newCapacity - 1;
+ capacity = newCapacity;
+ push = dst;
+ newPush = push + 1; /* no need modulo */
+ }
+
+ elements[push] = dataPtr;
+ push = newPush;
+
+ return true;
+ }
+
+
+ /* =============================================================================
+ * Pqueue_push
+ * =============================================================================
+ */
+ public boolean
+ Pqueue_push (Queue_t queuePtr, Object dataPtr)
+ {
+ int pop = queuePtr.pop;
+ int push = queuePtr.push;
+ int capacity = queuePtr.capacity;
+
+ if(pop == push) {
+ System.out.println("push == pop in Queue.java");
+ return false;
+ }
+
+ /* Need to resize */
+ int newPush = (push + 1) % capacity;
+ if (newPush == pop) {
+
+ int newCapacity = capacity * QUEUE_GROWTH_FACTOR;
+ Object[] newElements = new Object[newCapacity];
+ if (newElements == null) {
+ return false;
+ }
+
+ int dst = 0;
+ Object[] elements = queuePtr.elements;
+ if (pop < push) {
+ int src;
+ for (src = (pop + 1); src < push; src++, dst++) {
+ newElements[dst] = elements[src];
+ }
+ } else {
+ int src;
+ for (src = (pop + 1); src < capacity; src++, dst++) {
+ newElements[dst] = elements[src];
+ }
+ for (src = 0; src < push; src++, dst++) {
+ newElements[dst] = elements[src];
+ }
+ }
+
+ elements = null;
+ queuePtr.elements = newElements;
+ queuePtr.pop = newCapacity - 1;
+ queuePtr.capacity = newCapacity;
+ push = dst;
+ newPush = push + 1; /* no need modulo */
+
+ }
+
+ queuePtr.elements[push] = dataPtr;
+ queuePtr.push = newPush;
+
+ return true;
+ }
+
+ /* =============================================================================
+ * queue_pop
+ * =============================================================================
+ */
+ public Object
+ //queue_pop (Queue queuePtr)
+ queue_pop ()
+ {
+ //int pop = queuePtr.pop;
+ //int push = queuePtr.push;
+ //int capacity = queuePtr.capacity;
+
+ int newPop = (pop + 1) % capacity;
+ if (newPop == push) {
+ return null;
+ }
+
+ //Object dataPtr = queuePtr.elements[newPop];
+ //queuePtr.pop = newPop;
+ Object dataPtr = elements[newPop];
+ pop = newPop;
+
+ return dataPtr;
+ }
+
+
+}
+/* =============================================================================
+ *
+ * End of queue.java
+ *
+ * =============================================================================
+ */
--- /dev/null
+public class QuickSort {
+ public QuickSort() {
+
+ }
+
+ /**
+ * Sort an array of Objects into ascending order. The sort algorithm is an optimised
+ * quicksort, as described in Jon L. Bentley and M. Douglas McIlroy's
+ * "Engineering a Sort Function", Software-Practice and Experience, Vol.
+ * 23(11) P. 1249-1265 (November 1993). This algorithm gives nlog(n)
+ * performance on many arrays that would take quadratic time with a standard
+ * quicksort.
+ *
+ * @param a the array to sort
+ */
+ public void sort(Object[] a)
+ {
+ qsort(a, 0, a.length);
+ }
+
+ public void sort(Object[] a, int fromIndex, int toIndex)
+ {
+ qsort(a, fromIndex, toIndex);
+ }
+
+ private int med3(int a, int b, int c, Object[]d)
+ {
+ if(less(d[a], d[b])) {
+ if(less(d[b], d[c])) {
+ return b;
+ } else {
+ if(less(d[a], d[c]))
+ return c;
+ else
+ return a;
+ }
+ } else {
+ if(less(d[c], d[b])) {
+ return b;
+ } else {
+ if(less(d[c], d[a]))
+ return c;
+ else
+ return a;
+ }
+ }
+ }
+
+ private void swap(int i, int j, Object[] a)
+ {
+ Object c = a[i];
+ a[i] = a[j];
+ a[j] = c;
+ }
+
+ private void qsort(Object[] a, int start, int n)
+ {
+ // use an insertion sort on small arrays
+ if (n <= 7)
+ {
+ for (int i = start + 1; i < start + n; i++)
+ for (int j = i; j > 0 && less(a[j], a[j - 1]); j--)
+ swap(j, j - 1, a);
+ return;
+ }
+
+ int pm = n / 2; // small arrays, middle element
+ if (n > 7)
+ {
+ int pl = start;
+ int pn = start + n - 1;
+
+ if (n > 40)
+ { // big arrays, pseudomedian of 9
+ int s = n / 8;
+ pl = med3(pl, pl + s, pl + 2 * s, a);
+ pm = med3(pm - s, pm, pm + s, a);
+ pn = med3(pn - 2 * s, pn - s, pn, a);
+ }
+ pm = med3(pl, pm, pn, a); // mid-size, med of 3
+ }
+
+ int pa, pb, pc, pd, pv;
+ int r;
+
+ pv = start;
+ swap(pv, pm, a);
+ pa = pb = start;
+ pc = pd = start + n - 1;
+
+ while(true)
+ {
+ while (pb <= pc && (r = diff(a[pb],a[pv])) <= 0)
+ {
+ if (r == 0)
+ {
+ swap(pa, pb, a);
+ pa++;
+ }
+ pb++;
+ }
+ while (pc >= pb && (r = diff(a[pc],a[pv])) >= 0)
+ {
+ if (r == 0)
+ {
+ swap(pc, pd, a);
+ pd--;
+ }
+ pc--;
+ }
+ if (pb > pc)
+ break;
+ swap(pb, pc, a);
+ pb++;
+ pc--;
+ }
+ int pn = start + n;
+ int s;
+ s = Math.imin(pa - start, pb - pa);
+ vecswap(start, pb - s, s, a);
+ s = Math.imin(pd - pc, pn - pd - 1);
+ vecswap(pb, pn - s, s, a);
+ if ((s = pb - pa) > 1)
+ qsort(a, start, s);
+ if ((s = pd - pc) > 1)
+ qsort(a, pn - s, s);
+ }
+
+ private void vecswap(int i, int j, int n, Object[] a)
+ {
+ for (; n > 0; i++, j++, n--)
+ swap(i, j, a);
+ }
+
+ public boolean less(Object x, Object y) {
+ Query aQueryPtr = (Query) x;
+ Query bQueryPtr = (Query) y;
+ if(aQueryPtr.index < bQueryPtr.index)
+ return true;
+ return false;
+ }
+
+ public int diff(Object x, Object y) {
+ Query aQueryPtr = (Query) x;
+ Query bQueryPtr = (Query) y;
+ return (aQueryPtr.index - bQueryPtr.index);
+ }
+
+ /**
+ * main to test quick sort
+ **/
+ /*
+ public static void main(String[] args) {
+ QuickSort qs = new QuickSort();
+ Query[] queries = new Query[10];
+
+ Random r = new Random();
+ r.random_alloc();
+ r.random_seed(0);
+
+ for(int i = 0; i<10; i++) {
+ queries[i] = new Query();
+ queries[i].index = (int) (r.random_generate() % 100);
+ queries[i].value = -1;
+ }
+
+ System.out.println("Before sorting");
+ for(int i = 0; i<10; i++)
+ System.out.println("queries["+i+"]= "+ queries[i]);
+
+ qs.sort(queries);
+
+ System.out.println("After sorting");
+ for(int i = 0; i<10; i++)
+ System.out.println("queries["+i+"]= "+ queries[i]);
+ }
+ */
+}
--- /dev/null
+/* =============================================================================
+ *
+ * Router.java
+ *
+ * =============================================================================
+ *
+ * Copyright (C) Stanford University, 2006. All Rights Reserved.
+ * Author: Chi Cao Minh
+ *
+ * Ported to Java
+ * Author: Jihoon Lee
+ * University of California, Irvine
+ *
+ * =============================================================================
+ *
+ * For the license of bayes/sort.h and bayes/sort.c, please see the header
+ * of the files.
+ *
+ * ------------------------------------------------------------------------
+ *
+ * For the license of kmeans, please see kmeans/LICENSE.kmeans
+ *
+ * ------------------------------------------------------------------------
+ *
+ * For the license of ssca2, please see ssca2/COPYRIGHT
+ *
+ * ------------------------------------------------------------------------
+ *
+ * For the license of lib/mt19937ar.c and lib/mt19937ar.h, please see the
+ * header of the files.
+ *
+ * ------------------------------------------------------------------------
+ *
+ * For the license of lib/rbtree.h and lib/rbtree.c, please see
+ * lib/LEGALNOTICE.rbtree and lib/LICENSE.rbtree
+ *
+ * ------------------------------------------------------------------------
+ *
+ * Unless otherwise noted, the following license applies to STAMP files:
+ *
+ * Copyright (c) 2007, Stanford University
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Stanford University nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY STANFORD UNIVERSITY ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * =============================================================================
+ */
+
+#define MOMENTUM_ZERO 0
+#define MOMENTUM_POSX 1
+#define MOMENTUM_POSY 2
+#define MOMENTUM_POSZ 3
+#define MOMENTUM_NEGX 4
+#define MOMENTUM_NEGY 5
+#define MOMENTUM_NEGZ 6
+#define GRID_POINT_FULL -2
+#define GRID_POINT_EMPTY -1
+
+public class Router {
+ public int xCost;
+ public int yCost;
+ public int zCost;
+ public int bendCost;
+ public static Point MOVE_POSX;
+ public static Point MOVE_POSY;
+ public static Point MOVE_POSZ;
+ public static Point MOVE_NEGX;
+ public static Point MOVE_NEGY;
+ public static Point MOVE_NEGZ;
+
+ public Router() {}
+
+/* =============================================================================
+ * router_alloc
+ * =============================================================================
+ * router_t* router_alloc (long xCost, long yCost, long zCost, long bendCost);
+ */
+ public static Router alloc(int xCost,int yCost,int zCost,int bendCost) {
+ Router routerPtr = new Router();
+
+
+ routerPtr.MOVE_POSX = new Point(1,0,0,0,MOMENTUM_POSX);
+ routerPtr.MOVE_POSY = new Point(0,1,0,0,MOMENTUM_POSY);
+ routerPtr.MOVE_POSZ = new Point(0,0,1,0,MOMENTUM_POSZ);
+ routerPtr.MOVE_NEGX = new Point(-1,0,0,0,MOMENTUM_NEGX);
+ routerPtr.MOVE_NEGY = new Point(0,-1,0,0,MOMENTUM_NEGY);
+ routerPtr.MOVE_NEGZ = new Point(0,0,-1,0,MOMENTUM_NEGZ);
+
+ if(routerPtr != null) {
+ routerPtr.xCost = xCost;
+ routerPtr.yCost = yCost;
+ routerPtr.zCost = zCost;
+ routerPtr.bendCost = bendCost;
+ }
+
+ return routerPtr;
+ }
+
+
+/* ============================================================================
+ * PexpandToneighbor
+ * ============================================================================
+ */
+ private void PexpandToNeighbor(Grid myGridPtr,
+ int x,int y,int z, int value,Queue_Int queuePtr) {
+ if (myGridPtr.isPointValid(x,y,z)) {
+ int neighborValue = myGridPtr.points_unaligned[x][y][z];
+ if (neighborValue == GRID_POINT_EMPTY) {
+ int neighborGridPointIndex = myGridPtr.getPointIndex(x,y,z);
+ myGridPtr.points_unaligned[x][y][z] = value;
+ queuePtr.queue_push(neighborGridPointIndex);
+ } else if (neighborValue != GRID_POINT_FULL) {
+ if (value < neighborValue) {
+ int neighborGridPointIndex = myGridPtr.getPointIndex(x,y,z);
+ myGridPtr.points_unaligned[x][y][z] = value;
+ queuePtr.queue_push(neighborGridPointIndex);
+ }
+ }
+ }
+ }
+
+
+/* ============================================================================
+ * PdoExpansion
+ * ============================================================================
+ */
+ public boolean PdoExpansion (Router routerPtr,Grid myGridPtr,Queue_Int queuePtr,
+ Coordinate srcPtr,Coordinate dstPtr) {
+ int xCost = routerPtr.xCost;
+ int yCost = routerPtr.yCost;
+ int zCost = routerPtr.zCost;
+
+ /*
+ * Potential Optimization: Make 'src' the one closet to edge.
+ * This will likely decrease the area of the emitted wave.
+ */
+
+ queuePtr.queue_clear();
+
+ int srcGridPointIndex = myGridPtr.getPointIndex(srcPtr.x,srcPtr.y,srcPtr.z);
+
+ queuePtr.queue_push(srcGridPointIndex);
+
+ myGridPtr.setPoint(srcPtr.x,srcPtr.y,srcPtr.z,0);
+ myGridPtr.setPoint(dstPtr.x,dstPtr.y,dstPtr.z,GRID_POINT_EMPTY);
+ int dstGridPointIndex = myGridPtr.getPointIndex(dstPtr.x,dstPtr.y,dstPtr.z);
+ boolean isPathFound = false;
+ int height = myGridPtr.height;
+ int width = myGridPtr.width;
+ int area = height * width;
+ while (!queuePtr.queue_isEmpty()) {
+ int gridPointIndex = queuePtr.queue_pop();
+
+ if(gridPointIndex == dstGridPointIndex) {
+ isPathFound = true;
+ break;
+ }
+
+ int z = gridPointIndex / area;
+ int index2d = gridPointIndex % area;
+ int y = index2d / width;
+ int x = index2d % width;
+ int value = myGridPtr.points_unaligned[x][y][z];
+
+ /*
+ * Check 6 neighbors
+ *
+ * Potential Optimization: Only need to check 5 of these
+ */
+ PexpandToNeighbor(myGridPtr, x+1, y, z, (value + xCost), queuePtr);
+ PexpandToNeighbor(myGridPtr, x-1, y, z, (value + xCost), queuePtr);
+ PexpandToNeighbor(myGridPtr, x, y+1, z, (value + yCost), queuePtr);
+ PexpandToNeighbor(myGridPtr, x, y-1, z, (value + yCost), queuePtr);
+ PexpandToNeighbor(myGridPtr, x, y, z+1, (value + zCost), queuePtr);
+ PexpandToNeighbor(myGridPtr, x, y, z-1, (value + zCost), queuePtr);
+
+ } /* iterate over work queue */
+
+ return isPathFound;
+ }
+
+
+/* ============================================================================
+ * traceToNeighbor
+ * ============================================================================
+ */
+ private void traceToNeighbor(Grid myGridPtr,
+ Point currPtr,
+ Point movePtr,
+ boolean useMomentum,
+ int bendCost,
+ Point nextPtr)
+ {
+ int x = currPtr.x + movePtr.x;
+ int y = currPtr.y + movePtr.y;
+ int z = currPtr.z + movePtr.z;
+
+ if (myGridPtr.isPointValid(x,y,z) &&
+ !myGridPtr.isPointEmpty(x,y,z) &&
+ !myGridPtr.isPointFull(x,y,z))
+ {
+ int value = myGridPtr.getPoint(x,y,z);
+ int b = 0;
+
+ if (useMomentum && (currPtr.momentum != movePtr.momentum)) {
+ b = bendCost;
+ }
+ if ((value + b) <= nextPtr.value) { /* '=' favors neighbors over current */
+ nextPtr.x = x;
+ nextPtr.y = y;
+ nextPtr.z = z;
+ nextPtr.value = value;
+ nextPtr.momentum = movePtr.momentum;
+ }
+ }
+ }
+/* =============================================================================
+ * PdoTraceback
+ * =============================================================================
+ */
+
+ private Vector_t PdoTraceback(Grid myGridPtr,
+ Coordinate dstPtr, int bendCost) {
+ Vector_t pointVectorPtr = Vector_t.vector_alloc(1);
+
+ Point next = new Point();
+ next.x = dstPtr.x;
+ next.y = dstPtr.y;
+ next.z = dstPtr.z;
+ next.value = myGridPtr.getPoint(next.x,next.y,next.z);
+ next.momentum = MOMENTUM_ZERO;
+
+ while(true) {
+ int gridPointIndex = myGridPtr.getPointIndex(next.x,next.y,next.z);
+ pointVectorPtr.vector_pushBack(new Integer(gridPointIndex));
+ myGridPtr.setPoint(next.x,next.y,next.z,GRID_POINT_FULL);
+
+ /* Check if we are done */
+ if (next.value == 0) {
+ break;
+ }
+ Point curr = new Point();
+ curr.x = next.x;
+ curr.y = next.y;
+ curr.z = next.z;
+ curr.value = next.value;
+ curr.momentum = next.momentum;
+
+ /*
+ * Check 6 neibors
+ */
+
+ traceToNeighbor(myGridPtr,curr,MOVE_POSX,true, bendCost, next);
+ traceToNeighbor(myGridPtr,curr,MOVE_POSY,true, bendCost, next);
+ traceToNeighbor(myGridPtr,curr,MOVE_POSZ,true, bendCost, next);
+ traceToNeighbor(myGridPtr,curr,MOVE_NEGX,true, bendCost, next);
+ traceToNeighbor(myGridPtr,curr,MOVE_NEGY,true, bendCost, next);
+ traceToNeighbor(myGridPtr,curr,MOVE_NEGZ,true, bendCost, next);
+ /*
+ * Because of bend costs, none of the neighbors may appear to be closer.
+ * In this case, pick a neighbor while ignoring momentum.
+ */
+
+
+
+ if ((curr.x == next.x) &&
+ (curr.y == next.y) &&
+ (curr.z == next.z)) {
+ next.value = curr.value;
+ traceToNeighbor(myGridPtr,curr,MOVE_POSX,false, bendCost, next);
+ traceToNeighbor(myGridPtr,curr,MOVE_POSY,false, bendCost, next);
+ traceToNeighbor(myGridPtr,curr,MOVE_POSZ,false, bendCost, next);
+ traceToNeighbor(myGridPtr,curr,MOVE_NEGX,false, bendCost, next);
+ traceToNeighbor(myGridPtr,curr,MOVE_NEGY,false, bendCost, next);
+ traceToNeighbor(myGridPtr,curr,MOVE_NEGZ,false, bendCost, next);
+
+ if ((curr.x == next.x) &&
+ (curr.y == next.y) &&
+ (curr.z == next.z)) {
+ System.out.println("Dead");
+ return null;
+ }
+ }
+ }
+
+ return pointVectorPtr;
+ }
+
+/* =============================================================================
+ * router_solve
+ * =============================================================================
+ * void router_solve (void* argPtr);
+ */
+ public static void solve(Object argPtr)
+ {
+ // TM_THREAD_ENTER();
+ //
+ Solve_Arg routerArgPtr = (Solve_Arg) argPtr;
+ Router routerPtr = routerArgPtr.routerPtr;
+ Maze mazePtr = routerArgPtr.mazePtr;
+ Vector_t myPathVectorPtr = Vector_t.vector_alloc(1);
+
+ Queue_t workQueuePtr = mazePtr.workQueuePtr;
+ Grid gridPtr = mazePtr.gridPtr;
+ Grid myGridPtr = Grid.scratchalloc(gridPtr.width,gridPtr.height,gridPtr.depth);
+ int bendCost = routerPtr.bendCost;
+ Queue_Int myExpansionQueuePtr = Queue_Int.queue_alloc(-1);
+
+ /*
+ * Iterate over work list to route each path. This involves an
+ * 'expansion' and 'tracback' phase for each source/destination pair.
+ */
+ while(true) {
+ Pair coordinatePairPtr;
+
+ // TM_BEGIN();
+ atomic {
+ if(workQueuePtr.queue_isEmpty()) {
+ coordinatePairPtr = null;
+ } else {
+ coordinatePairPtr = (Pair)workQueuePtr.queue_pop();
+ }
+ }
+ // TM_END();
+ //
+
+ if (coordinatePairPtr == null) {
+ break;
+ }
+
+ Coordinate srcPtr = (Coordinate)coordinatePairPtr.first;
+ Coordinate dstPtr = (Coordinate)coordinatePairPtr.second;
+
+// System.out.println("SRC x = " + srcPtr.x + " y = " + srcPtr.y + " z = " +srcPtr.z);
+
+ boolean success = false;
+ Vector_t pointVectorPtr = null;
+ boolean retry=true;
+
+ // TM_BEGIN();
+ while(retry) {
+ retry=false;
+ atomic {
+ Grid.copy(myGridPtr, gridPtr); /* ok if not most up-to-date */
+ if(routerPtr.PdoExpansion(routerPtr,myGridPtr,myExpansionQueuePtr,srcPtr,dstPtr)) {
+ pointVectorPtr = routerPtr.PdoTraceback(myGridPtr,dstPtr,bendCost);
+ if (pointVectorPtr != null) {
+ if (gridPtr.TM_addPath(pointVectorPtr)) {
+ pointVectorPtr=null;
+ retry=true;
+ } else
+ success=true;
+ }
+ }
+ }
+ }
+
+ if(success) {
+ boolean status = myPathVectorPtr.vector_pushBack(pointVectorPtr);
+
+ if(!status) {
+ System.out.println("Assert in Router_Solve");
+ System.exit(1);
+ }
+ }
+ }
+
+ /*
+ * Add my paths to global list
+ */
+ List_t pathVectorListPtr = routerArgPtr.pathVectorListPtr;
+
+ atomic {
+ pathVectorListPtr.insert(myPathVectorPtr);
+ }
+
+ myGridPtr = null;
+ myExpansionQueuePtr = null;
+// System.out.println("Final Grid: ");
+// gridPtr.print();
+
+ // TM_THREAD_EXIT();
+ }
+}
+/* =============================================================================
+ *
+ * End of router.java
+ *
+ * =============================================================================
+ */
--- /dev/null
+public class SmallTest {
+ public SmallTest() {}
+
+ public static void main(String qweqwe[]) {
+ atomic {
+ Vector_t pointVectorPtr = Vector_t.vector_alloc(1);
+ int i=3;
+ while(true) {
+ pointVectorPtr.vector_pushBack(new Integer(i));
+ if (i==5) {
+ break;
+ }
+ }
+ int n = pointVectorPtr.vector_getSize();
+
+ for(i = 0; i < n; i++) {
+ int gridPointIndex = ((Integer)(pointVectorPtr.vector_at(i))).intValue();
+ }
+ }
+ }
+}
--- /dev/null
+
+
+ public class Solve_Arg {
+ Router routerPtr;
+ Maze mazePtr;
+ List_t pathVectorListPtr;
+
+ public Solve_Arg(Router r,Maze m,List_t l)
+ {
+ routerPtr = r;
+ mazePtr = m;
+ pathVectorListPtr = l;
+ }
+ }
+
--- /dev/null
+public class Vector_t {
+ int size;
+ int capacity;
+ Object[] elements;
+// QuickSort qsort;
+
+ public Vector_t() {
+// qsort = new QuickSort();
+ }
+
+ /* =============================================================================
+ * Vector_alloc
+ * -- Returns null if failed
+ * =============================================================================
+ */
+ public static Vector_t vector_alloc (int initCapacity) {
+ int capacity = Math.imax(initCapacity, 1);
+ Vector_t vectorPtr = new Vector_t();
+ if(vectorPtr != null) {
+ vectorPtr.size = 0;
+ vectorPtr.capacity = capacity;
+ vectorPtr.elements = new Object[capacity];
+ if(vectorPtr.elements == null)
+ return null;
+ }
+ return vectorPtr;
+ }
+
+ /* =============================================================================
+ * Vector_free
+ * =============================================================================
+ */
+ public void
+ vector_free ()
+ {
+ elements = null;
+ }
+
+ /* =============================================================================
+ * Vector_at
+ * -- Returns null if failed
+ * =============================================================================
+ */
+ public Object vector_at (int i) {
+ if ((i < 0) || (i >= size)) {
+ System.out.println("Illegal Vector.element\n");
+ return null;
+ }
+ return (elements[i]);
+ }
+
+
+ /* =============================================================================
+ * Vector_pushBack
+ * -- Returns false if fail, else true
+ * =============================================================================
+ */
+ public boolean vector_pushBack (Object dataPtr) {
+ if (size == capacity) {
+ int newCapacity = capacity * 2;
+ Object[] newElements = new Object[newCapacity];
+
+ //void** newElements = (void**)malloc(newCapacity * sizeof(void*));
+ if (newElements == null) {
+ return false;
+ }
+ capacity = newCapacity;
+ for (int i = 0; i < size; i++) {
+ newElements[i] = elements[i];
+ }
+ elements = null;
+ elements = newElements;
+ }
+
+ elements[size++] = dataPtr;
+
+ return true;
+ }
+
+ /* =============================================================================
+ * Vector_popBack
+ * -- Returns null if fail, else returns last element
+ * =============================================================================
+ */
+ public Object
+ vector_popBack ()
+ {
+ if (size < 1) {
+ return null;
+ }
+
+ return (elements[--(size)]);
+ }
+
+ /* =============================================================================
+ * Vector_getSize
+ * =============================================================================
+ */
+ public int
+ vector_getSize ()
+ {
+ return (size);
+ }
+
+ /* =============================================================================
+ * Vector_clear
+ * =============================================================================
+ */
+ public void
+ vector_clear ()
+ {
+ size = 0;
+ }
+
+ /* =============================================================================
+ * Vector_sort
+ * =============================================================================
+ *
+ public void
+ vector_sort ()
+ {
+ //qsort.sort(elements, 0, (elements.length - 1));
+ qsort.sort(elements);
+ //qsort(elements, size, 4, compare);
+ }
+
+ * =============================================================================
+ * Vector_copy
+ * =============================================================================
+ */
+ public static boolean
+ vector_copy (Vector_t dstVectorPtr, Vector_t srcVectorPtr)
+ {
+ int dstCapacity = dstVectorPtr.capacity;
+ int srcSize = srcVectorPtr.size;
+ if (dstCapacity < srcSize) {
+ int srcCapacity = srcVectorPtr.capacity;
+ Object[] elements = new Object[srcCapacity];
+
+ if (elements == null) {
+ return false;
+ }
+ dstVectorPtr.elements = null;
+ dstVectorPtr.elements = elements;
+ dstVectorPtr.capacity = srcCapacity;
+ }
+
+ for(int i = 0; i< srcSize; i++) {
+ dstVectorPtr.elements[i] = srcVectorPtr.elements[i];
+ }
+
+ dstVectorPtr.size = srcSize;
+
+ return true;
+ }
+}
--- /dev/null
+#!/bin/sh
+lines=$(grep -n "#" $1 | cut -d: -f1 | sed '1q')
+sed '/^#/d' $1 > ttt$1
--- /dev/null
+#!/bin/env python
+
+import random
+import sys
+
+if len(sys.argv) != 5:
+ print "Usage: ./generate.py x y z n"
+ sys.exit(1)
+
+x = int(sys.argv[1])
+y = int(sys.argv[2])
+z = int(sys.argv[3])
+numPath = int(sys.argv[4])
+
+random.seed(0)
+
+print "# Dimensions (x, y, z)"
+print "d %i %i %i" % (x, y, z)
+print ""
+print "# Paths: Sources (x, y, z) -> Destinations (x, y, z)"
+for i in range(numPath):
+ src = (random.randint(0, x-1), random.randint(0, y-1), random.randint(0, z-1))
+ while 1:
+ dst = (random.randint(0, x-1), random.randint(0, y-1), random.randint(0, z-1))
+ if dst != src:
+ break;
+ print "p %3i %3i %1i %3i %3i %1i" % (src[0], src[1], src[2], dst[0], dst[1], dst[2])
--- /dev/null
+# Dimensions (x, y, z)
+d 128 128 3
+
+# Paths: Sources (x, y, z) -> Destinations (x, y, z)
+p 108 97 1 33 65 1
+p 100 38 1 74 116 1
+p 36 96 1 32 116 2
+p 103 115 0 93 115 2
+p 60 12 1 78 116 2
+p 61 110 0 103 70 0
+p 92 51 2 85 0 1
+p 111 31 0 111 24 1
+p 30 123 2 57 10 0
+p 65 119 0 70 90 1
+p 104 69 2 77 75 1
+p 76 49 1 37 24 0
+p 78 84 1 11 96 2
+p 118 107 2 118 69 1
+p 90 35 2 108 114 1
+p 121 74 1 84 127 2
+p 101 10 1 62 80 2
+p 31 93 0 28 101 0
+p 104 12 0 89 5 1
+p 116 68 2 3 81 1
+p 73 50 1 125 4 0
+p 123 23 0 26 102 2
+p 2 54 0 33 28 1
+p 44 23 1 5 12 2
+p 25 45 2 107 117 0
+p 86 123 0 86 108 1
+p 32 76 1 22 60 1
+p 72 65 0 45 107 0
+p 71 1 2 42 5 0
+p 30 122 1 36 45 2
+p 81 79 2 49 53 1
+p 0 24 1 30 81 1
+p 112 72 1 51 89 1
+p 84 5 1 33 20 1
+p 62 71 2 113 63 0
+p 59 103 2 103 24 2
+p 81 10 2 126 51 2
+p 40 27 2 0 105 1
+p 12 15 1 111 35 2
+p 12 109 1 10 35 1
+p 101 110 0 66 83 1
+p 111 35 0 5 87 1
+p 121 120 2 5 95 2
+p 83 91 2 81 47 1
+p 26 75 0 19 42 2
+p 91 43 1 5 20 2
+p 37 50 1 37 61 0
+p 6 22 1 9 51 0
+p 53 12 2 60 107 2
+p 43 61 2 54 38 2
+p 114 117 1 48 124 1
+p 8 10 2 7 1 1
+p 66 57 1 74 86 1
+p 47 126 0 99 55 1
+p 8 110 2 115 57 2
+p 15 50 0 5 121 0
+p 18 25 1 69 19 2
+p 125 18 1 87 112 1
+p 117 41 1 63 85 0
+p 78 28 1 123 115 2
+p 4 18 0 100 107 1
+p 91 103 0 10 111 0
+p 28 5 0 108 42 0
+p 19 83 2 64 115 1
+p 73 86 2 97 126 2
+p 115 26 1 76 105 1
+p 101 49 1 108 102 1
+p 0 23 1 32 8 2
+p 120 38 1 103 7 1
+p 16 36 2 7 4 1
+p 62 110 2 86 19 2
+p 52 78 1 6 60 0
+p 4 79 1 13 70 1
+p 49 99 1 112 78 1
+p 80 43 0 87 79 2
+p 16 116 2 117 111 2
+p 103 66 2 24 100 1
+p 96 58 2 9 5 2
+p 62 115 2 85 73 0
+p 11 104 2 99 89 1
+p 39 14 1 72 118 2
+p 53 12 2 93 3 1
+p 87 3 2 123 92 0
+p 9 45 0 44 1 2
+p 104 9 2 26 26 2
+p 120 15 0 47 3 1
+p 109 23 0 44 122 0
+p 123 46 1 37 119 2
+p 81 23 2 13 74 0
+p 114 121 2 40 31 2
+p 37 53 0 16 2 0
+p 9 53 1 94 18 1
+p 81 10 1 47 121 0
+p 52 53 2 41 26 0
+p 60 121 2 35 71 2
+p 101 57 1 98 55 0
+p 58 119 0 59 81 1
+p 26 0 2 79 0 0
+p 98 80 1 19 90 1
+p 86 97 0 97 35 2
+p 15 113 0 32 67 1
+p 50 13 0 36 96 2
+p 76 4 2 39 43 1
+p 31 117 0 53 37 1
+p 73 80 1 52 81 1
+p 99 100 0 47 80 0
+p 89 48 1 17 85 1
+p 60 53 1 88 40 1
+p 7 38 2 6 79 0
+p 60 113 0 67 8 2
+p 87 94 2 0 5 1
+p 127 111 2 93 29 2
+p 36 13 1 42 21 1
+p 114 55 1 90 67 0
+p 116 56 2 49 103 1
+p 28 25 2 75 6 1
+p 29 10 0 7 81 0
+p 78 78 2 65 36 2
+p 45 58 1 66 122 2
+p 119 119 1 62 90 0
+p 34 5 0 0 83 0
+p 100 87 2 50 117 1
+p 43 13 2 101 41 1
+p 41 3 0 47 26 1
+p 24 25 2 94 39 2
+p 32 44 2 5 119 0
+p 58 92 0 103 125 1
+p 15 10 0 97 52 2
--- /dev/null
+# Dimensions (x, y, z)
+d 128 128 3
+
+# Paths: Sources (x, y, z) -> Destinations (x, y, z)
+p 108 97 1 33 65 1
+p 100 38 1 74 116 1
+p 36 96 1 32 116 2
+p 103 115 0 93 115 2
+p 60 12 1 78 116 2
+p 61 110 0 103 70 0
+p 92 51 2 85 0 1
+p 111 31 0 111 24 1
+p 30 123 2 57 10 0
+p 65 119 0 70 90 1
+p 104 69 2 77 75 1
+p 76 49 1 37 24 0
+p 78 84 1 11 96 2
+p 118 107 2 118 69 1
+p 90 35 2 108 114 1
+p 121 74 1 84 127 2
+p 101 10 1 62 80 2
+p 31 93 0 28 101 0
+p 104 12 0 89 5 1
+p 116 68 2 3 81 1
+p 73 50 1 125 4 0
+p 123 23 0 26 102 2
+p 2 54 0 33 28 1
+p 44 23 1 5 12 2
+p 25 45 2 107 117 0
+p 86 123 0 86 108 1
+p 32 76 1 22 60 1
+p 72 65 0 45 107 0
+p 71 1 2 42 5 0
+p 30 122 1 36 45 2
+p 81 79 2 49 53 1
+p 0 24 1 30 81 1
+p 112 72 1 51 89 1
+p 84 5 1 33 20 1
+p 62 71 2 113 63 0
+p 59 103 2 103 24 2
+p 81 10 2 126 51 2
+p 40 27 2 0 105 1
+p 12 15 1 111 35 2
+p 12 109 1 10 35 1
+p 101 110 0 66 83 1
+p 111 35 0 5 87 1
+p 121 120 2 5 95 2
+p 83 91 2 81 47 1
+p 26 75 0 19 42 2
+p 91 43 1 5 20 2
+p 37 50 1 37 61 0
+p 6 22 1 9 51 0
+p 53 12 2 60 107 2
+p 43 61 2 54 38 2
+p 114 117 1 48 124 1
+p 8 10 2 7 1 1
+p 66 57 1 74 86 1
+p 47 126 0 99 55 1
+p 8 110 2 115 57 2
+p 15 50 0 5 121 0
+p 18 25 1 69 19 2
+p 125 18 1 87 112 1
+p 117 41 1 63 85 0
+p 78 28 1 123 115 2
+p 4 18 0 100 107 1
+p 91 103 0 10 111 0
+p 28 5 0 108 42 0
+p 19 83 2 64 115 1
--- /dev/null
+# Dimensions (x, y, z)
+d 128 128 5
+
+# Paths: Sources (x, y, z) -> Destinations (x, y, z)
+p 108 97 2 33 65 2
+p 100 38 2 74 116 2
+p 36 96 3 32 116 4
+p 103 115 1 93 115 3
+p 60 12 2 78 116 4
+p 61 110 1 103 70 0
+p 92 51 4 85 0 2
+p 111 31 1 111 24 2
+p 30 123 4 57 10 1
+p 65 119 0 70 90 2
+p 104 69 4 77 75 2
+p 76 49 2 37 24 0
+p 78 84 2 11 96 4
+p 118 107 4 118 69 1
+p 90 35 4 108 114 2
+p 121 74 2 84 127 4
+p 101 10 3 62 80 4
+p 31 93 0 28 101 1
+p 104 12 0 89 5 2
+p 116 68 3 3 81 3
+p 73 50 1 125 4 0
+p 123 23 0 26 102 4
+p 2 54 0 33 28 3
+p 44 23 2 5 12 4
+p 25 45 3 107 117 0
+p 86 123 0 86 108 1
+p 32 76 2 22 60 2
+p 72 65 1 45 107 1
+p 71 1 3 42 5 1
+p 30 122 1 36 45 4
+p 81 79 3 49 53 3
+p 0 24 1 30 81 1
+p 112 72 2 51 89 2
+p 84 5 2 33 20 2
+p 62 71 3 113 63 1
+p 59 103 4 103 24 4
+p 81 10 3 126 51 3
+p 40 27 3 0 105 2
+p 12 15 3 111 35 4
+p 12 109 1 10 35 2
+p 101 110 0 66 83 1
+p 111 35 0 5 87 2
+p 121 120 4 5 95 3
+p 83 91 4 81 47 2
+p 26 75 0 19 42 3
+p 91 43 3 5 20 4
+p 37 50 2 37 61 1
+p 6 22 2 9 51 1
+p 53 12 4 60 107 4
+p 43 61 3 54 38 3
+p 114 117 3 48 124 3
+p 8 10 3 7 1 1
+p 66 57 2 74 86 2
+p 47 126 1 99 55 1
+p 8 110 3 115 57 3
+p 15 50 1 5 121 1
+p 18 25 1 69 19 4
+p 125 18 2 87 112 2
+p 117 41 2 63 85 1
+p 78 28 1 123 115 4
+p 4 18 1 100 107 2
+p 91 103 0 10 111 0
+p 28 5 0 108 42 0
+p 19 83 4 64 115 2
+p 73 86 4 97 126 3
+p 115 26 2 76 105 2
+p 101 49 2 108 102 3
+p 0 23 2 32 8 4
+p 120 38 2 103 7 3
+p 16 36 4 7 4 2
+p 62 110 3 86 19 4
+p 52 78 1 6 60 0
+p 4 79 3 13 70 1
+p 49 99 2 112 78 2
+p 80 43 0 87 79 3
+p 16 116 3 117 111 3
+p 103 66 3 24 100 2
+p 96 58 3 9 5 4
+p 62 115 4 85 73 1
+p 11 104 4 99 89 2
+p 39 14 2 72 118 4
+p 53 12 3 93 3 2
+p 87 3 4 123 92 0
+p 9 45 0 44 1 4
+p 104 9 4 26 26 3
+p 120 15 0 47 3 3
+p 109 23 0 44 122 0
+p 123 46 2 37 119 4
+p 81 23 4 13 74 0
+p 114 121 4 40 31 3
+p 37 53 0 16 2 0
+p 9 53 2 94 18 2
+p 81 10 2 47 121 0
+p 52 53 3 41 26 1
+p 60 121 3 35 71 3
+p 101 57 1 98 55 1
+p 58 119 0 59 81 2
+p 26 0 3 79 0 1
+p 98 80 2 19 90 2
+p 86 97 1 97 35 4
+p 15 113 0 32 67 2
+p 50 13 1 36 96 4
+p 76 4 3 39 43 2
+p 31 117 0 53 37 2
+p 73 80 2 52 81 2
+p 99 100 1 47 80 0
+p 89 48 2 17 85 1
+p 60 53 2 88 40 3
+p 7 38 3 6 79 0
+p 60 113 0 67 8 4
+p 87 94 3 0 5 3
+p 127 111 3 93 29 3
+p 36 13 2 42 21 2
+p 114 55 2 90 67 0
+p 116 56 3 49 103 1
+p 28 25 4 75 6 1
+p 29 10 0 7 81 0
+p 78 78 3 65 36 4
+p 45 58 3 66 122 4
+p 119 119 2 62 90 1
+p 34 5 0 0 83 0
+p 100 87 4 50 117 2
+p 43 13 4 101 41 2
+p 41 3 0 47 26 2
+p 24 25 3 94 39 4
+p 32 44 3 5 119 0
+p 58 92 0 103 125 2
+p 15 10 0 97 52 4
--- /dev/null
+# Dimensions (x, y, z)
+d 256 256 3
+
+# Paths: Sources (x, y, z) -> Destinations (x, y, z)
+p 216 194 1 66 130 1
+p 200 77 1 149 232 1
+p 72 193 1 64 232 2
+p 207 230 0 186 230 2
+p 120 25 1 156 233 2
+p 122 221 0 206 140 0
+p 184 102 2 171 0 1
+p 222 62 0 222 48 1
+p 61 247 2 114 20 0
+p 130 238 0 141 180 1
+p 208 138 2 154 150 1
+p 152 98 1 74 48 0
+p 156 168 1 22 193 2
+p 236 215 2 236 138 1
+p 180 70 2 217 229 1
+p 243 148 1 169 255 2
+p 203 21 1 124 161 2
+p 62 187 0 56 203 0
+p 208 25 0 178 11 1
+p 232 136 2 6 162 1
+p 147 100 1 251 9 0
+p 246 47 0 53 204 2
+p 5 108 0 66 56 1
+p 89 46 1 10 25 2
+p 51 91 2 214 235 0
+p 172 247 0 173 216 1
+p 64 152 1 44 120 1
+p 145 130 0 91 214 0
+p 143 3 2 85 11 0
+p 61 244 1 73 91 2
+p 162 158 2 99 106 1
+p 0 49 1 61 163 1
+p 224 145 1 102 179 1
+p 169 11 1 66 40 1
+p 124 143 2 226 126 0
+p 119 207 2 207 48 2
+p 162 21 2 252 102 2
+p 80 54 2 0 210 1
+p 25 30 1 223 71 2
+p 25 218 1 20 70 1
+p 202 220 0 133 166 1
+p 223 71 0 10 174 1
+p 242 240 2 10 191 2
+p 167 182 2 163 95 1
+p 53 150 0 38 85 2
+p 183 86 1 10 41 2
+p 74 101 1 75 122 0
+p 12 45 1 18 103 0
+p 106 25 2 121 215 2
+p 87 122 2 109 77 2
+p 228 235 1 96 249 1
+p 16 21 2 15 2 1
+p 132 114 1 149 173 1
+p 94 253 0 198 110 1
+p 16 221 2 231 115 2
+p 30 101 0 10 242 0
+p 37 50 1 139 38 2
+p 251 37 1 174 224 1
+p 234 82 1 127 171 0
+p 156 56 1 246 230 2
+p 9 37 0 200 215 1
+p 183 206 0 21 222 0
+p 57 10 0 216 84 0
+p 38 167 2 129 230 1
+p 146 173 2 194 253 2
+p 231 52 1 153 211 1
+p 202 99 1 217 204 1
+p 0 46 1 65 16 2
+p 241 77 1 207 15 1
+p 32 73 2 14 9 1
+p 125 221 2 172 38 2
+p 105 156 1 12 120 0
+p 8 158 1 26 140 1
+p 98 198 1 225 156 1
+p 161 86 0 174 159 2
+p 32 233 2 234 223 2
+p 207 132 2 48 200 1
+p 193 116 2 19 11 2
+p 124 230 2 170 146 0
+p 23 209 2 199 178 1
+p 78 29 1 144 236 2
+p 106 25 2 187 7 1
+p 175 7 2 246 184 0
+p 18 91 0 89 2 2
+p 209 18 2 53 52 2
+p 240 31 0 94 6 1
+p 219 47 0 88 245 0
+p 247 92 1 74 239 2
+p 162 47 2 26 148 0
+p 229 242 2 80 62 2
+p 74 107 0 33 5 0
+p 18 107 1 189 36 1
+p 163 21 1 94 242 0
+p 104 106 2 82 52 0
+p 120 243 2 70 142 2
+p 203 114 1 196 110 0
+p 116 239 0 118 163 1
+p 52 0 2 158 1 0
+p 196 161 1 39 180 1
+p 173 194 0 195 71 2
+p 30 226 0 65 134 1
+p 101 26 0 72 193 2
+p 152 9 2 78 87 1
+p 63 235 0 106 74 1
+p 146 160 1 105 162 1
+p 199 201 0 95 160 0
+p 178 97 1 35 171 1
+p 121 106 1 177 81 1
+p 15 76 2 13 159 0
+p 120 227 0 134 17 2
+p 175 189 2 1 10 1
+p 255 223 2 186 58 2
+p 73 26 1 84 43 1
+p 229 111 1 181 134 0
+p 233 113 2 99 206 1
+p 56 50 2 150 12 1
+p 59 21 0 14 163 0
+p 156 156 2 131 72 2
+p 90 117 1 132 244 2
+p 238 239 1 125 180 0
+p 68 11 0 0 167 0
+p 201 174 2 101 235 1
+p 86 26 2 203 82 1
+p 83 7 0 94 53 1
+p 48 51 2 188 79 2
+p 65 88 2 11 239 0
+p 117 185 0 207 250 1
+p 30 20 0 195 105 2
+p 112 19 1 193 212 0
+p 46 125 0 222 239 0
+p 111 142 0 138 51 0
+p 113 154 1 66 59 0
+p 200 25 2 63 72 2
+p 168 189 1 219 31 1
+p 30 188 1 172 180 1
+p 56 212 0 132 172 0
+p 160 73 0 207 141 0
+p 149 6 0 101 249 1
+p 19 195 2 198 145 2
+p 54 187 2 194 90 1
+p 161 230 0 213 134 1
+p 116 3 0 167 169 1
+p 244 123 0 217 66 1
+p 180 210 2 98 15 0
+p 185 246 1 112 185 1
+p 66 171 0 91 138 2
+p 38 5 1 6 11 0
+p 167 17 0 248 108 2
+p 55 111 1 45 84 2
+p 191 97 1 67 136 2
+p 175 118 0 235 104 1
+p 0 35 2 131 187 0
+p 84 215 2 63 5 2
+p 43 201 2 43 20 2
+p 153 158 1 38 154 0
+p 206 187 0 238 9 0
+p 74 38 0 91 188 1
+p 69 126 1 79 230 1
+p 250 197 1 67 175 1
+p 184 103 1 5 189 0
+p 174 148 2 74 175 0
+p 135 87 2 248 53 1
+p 84 247 2 150 184 2
+p 90 234 2 84 191 0
+p 208 144 2 92 160 0
+p 200 153 2 0 36 0
+p 32 237 2 122 242 2
+p 199 191 0 140 108 2
+p 44 43 1 40 28 1
+p 203 154 2 68 72 1
+p 253 183 2 137 141 2
+p 48 200 2 216 192 0
+p 169 236 1 92 243 1
+p 105 157 2 58 4 1
+p 240 174 1 160 127 2
+p 63 228 0 241 237 0
+p 114 190 1 130 206 2
+p 245 42 2 237 162 2
+p 64 225 2 156 23 0
+p 2 64 2 98 198 1
+p 99 225 0 119 212 0
+p 181 83 0 121 133 0
+p 144 88 0 48 28 1
+p 11 237 2 241 80 2
+p 251 195 0 171 152 1
+p 78 15 0 34 123 1
+p 195 11 2 11 142 2
+p 161 243 1 149 21 1
+p 208 51 0 179 64 0
+p 239 255 0 230 141 0
+p 149 164 0 193 209 0
+p 165 116 0 117 40 1
+p 167 121 1 139 210 1
+p 208 20 1 90 115 2
+p 131 252 2 30 81 0
+p 187 4 2 49 105 0
+p 79 99 0 196 182 1
+p 213 19 0 90 230 2
+p 172 144 2 105 7 2
+p 48 99 1 31 89 0
+p 157 167 0 116 141 2
+p 126 20 0 220 202 2
+p 67 165 0 211 85 2
+p 120 8 2 160 73 0
+p 96 40 1 37 44 2
+p 163 62 2 159 242 1
+p 227 173 0 61 72 0
+p 60 57 2 118 224 0
+p 144 3 2 1 99 2
+p 255 4 2 130 9 2
+p 28 156 2 172 97 0
+p 111 233 0 63 35 1
+p 136 18 1 168 247 1
+p 111 120 0 101 165 1
+p 148 213 2 226 95 0
+p 156 121 0 10 82 2
+p 246 27 2 12 182 0
+p 107 222 1 236 182 1
+p 41 87 1 151 254 0
+p 128 238 1 160 196 1
+p 192 50 2 45 149 0
+p 162 74 1 174 68 2
+p 88 33 1 42 110 1
+p 19 181 2 199 139 1
+p 43 53 0 134 209 1
+p 225 188 2 85 30 2
+p 218 104 2 230 87 1
+p 84 177 2 252 190 0
+p 225 254 1 242 130 2
+p 254 208 2 39 1 1
+p 180 239 1 178 165 0
+p 164 251 0 176 157 1
+p 203 2 2 209 123 0
+p 115 149 0 124 198 2
+p 143 211 0 219 235 0
+p 211 217 2 132 155 0
+p 181 103 0 34 99 2
+p 144 234 2 22 150 1
+p 129 116 1 26 213 1
+p 165 121 0 138 40 2
+p 212 36 0 17 100 2
+p 142 67 0 28 36 2
+p 35 221 2 35 143 0
+p 220 142 2 125 176 2
+p 143 223 1 24 1 0
+p 214 79 0 126 242 1
+p 87 19 1 57 94 1
+p 194 59 2 190 123 2
+p 91 98 0 199 102 1
+p 120 167 1 234 110 1
+p 102 196 2 221 122 0
+p 114 88 0 47 244 1
+p 28 98 1 131 250 2
+p 144 158 2 128 124 0
+p 175 23 0 228 58 2
+p 251 147 0 23 51 0
--- /dev/null
+# Dimensions (x, y, z)
+d 256 256 5
+
+# Paths: Sources (x, y, z) -> Destinations (x, y, z)
+p 216 194 2 66 130 2
+p 200 77 2 149 232 2
+p 72 193 3 64 232 4
+p 207 230 1 186 230 3
+p 120 25 2 156 233 4
+p 122 221 1 206 140 0
+p 184 102 4 171 0 2
+p 222 62 1 222 48 2
+p 61 247 4 114 20 1
+p 130 238 0 141 180 2
+p 208 138 4 154 150 2
+p 152 98 2 74 48 0
+p 156 168 2 22 193 4
+p 236 215 4 236 138 1
+p 180 70 4 217 229 2
+p 243 148 2 169 255 4
+p 203 21 3 124 161 4
+p 62 187 0 56 203 1
+p 208 25 0 178 11 2
+p 232 136 3 6 162 3
+p 147 100 1 251 9 0
+p 246 47 0 53 204 4
+p 5 108 0 66 56 3
+p 89 46 2 10 25 4
+p 51 91 3 214 235 0
+p 172 247 0 173 216 1
+p 64 152 2 44 120 2
+p 145 130 1 91 214 1
+p 143 3 3 85 11 1
+p 61 244 1 73 91 4
+p 162 158 3 99 106 3
+p 0 49 1 61 163 1
+p 224 145 2 102 179 2
+p 169 11 2 66 40 2
+p 124 143 3 226 126 1
+p 119 207 4 207 48 4
+p 162 21 3 252 102 3
+p 80 54 3 0 210 2
+p 25 30 3 223 71 4
+p 25 218 1 20 70 2
+p 202 220 0 133 166 1
+p 223 71 0 10 174 2
+p 242 240 4 10 191 3
+p 167 182 4 163 95 2
+p 53 150 0 38 85 3
+p 183 86 3 10 41 4
+p 74 101 2 75 122 1
+p 12 45 2 18 103 1
+p 106 25 4 121 215 4
+p 87 122 3 109 77 3
+p 228 235 3 96 249 3
+p 16 21 3 15 2 1
+p 132 114 2 149 173 2
+p 94 253 1 198 110 1
+p 16 221 3 231 115 3
+p 30 101 1 10 242 1
+p 37 50 1 139 38 4
+p 251 37 2 174 224 2
+p 234 82 2 127 171 1
+p 156 56 1 246 230 4
+p 9 37 1 200 215 2
+p 183 206 0 21 222 0
+p 57 10 0 216 84 0
+p 38 167 4 129 230 2
+p 146 173 4 194 253 3
+p 231 52 2 153 211 2
+p 202 99 2 217 204 3
+p 0 46 2 65 16 4
+p 241 77 2 207 15 3
+p 32 73 4 14 9 2
+p 125 221 3 172 38 4
+p 105 156 1 12 120 0
+p 8 158 3 26 140 1
+p 98 198 2 225 156 2
+p 161 86 0 174 159 3
+p 32 233 3 234 223 3
+p 207 132 3 48 200 2
+p 193 116 3 19 11 4
+p 124 230 4 170 146 1
+p 23 209 4 199 178 2
+p 78 29 2 144 236 4
+p 106 25 3 187 7 2
+p 175 7 4 246 184 0
+p 18 91 0 89 2 4
+p 209 18 4 53 52 3
+p 240 31 0 94 6 3
+p 219 47 0 88 245 0
+p 247 92 2 74 239 4
+p 162 47 4 26 148 0
+p 229 242 4 80 62 3
+p 74 107 0 33 5 0
+p 18 107 2 189 36 2
+p 163 21 2 94 242 0
+p 104 106 3 82 52 1
+p 120 243 3 70 142 3
+p 203 114 1 196 110 1
+p 116 239 0 118 163 2
+p 52 0 3 158 1 1
+p 196 161 2 39 180 2
+p 173 194 1 195 71 4
+p 30 226 0 65 134 2
+p 101 26 1 72 193 4
+p 152 9 3 78 87 2
+p 63 235 0 106 74 2
+p 146 160 2 105 162 2
+p 199 201 1 95 160 0
+p 178 97 2 35 171 1
+p 121 106 2 177 81 3
+p 15 76 3 13 159 0
+p 120 227 0 134 17 4
+p 175 189 3 1 10 3
+p 255 223 3 186 58 3
+p 73 26 2 84 43 2
+p 229 111 2 181 134 0
+p 233 113 3 99 206 1
+p 56 50 4 150 12 1
+p 59 21 0 14 163 0
+p 156 156 3 131 72 4
+p 90 117 3 132 244 4
+p 238 239 2 125 180 1
+p 68 11 0 0 167 0
+p 201 174 4 101 235 2
+p 86 26 4 203 82 2
+p 83 7 0 94 53 2
+p 48 51 3 188 79 4
+p 65 88 3 11 239 0
+p 117 185 0 207 250 2
+p 30 20 0 195 105 4
+p 112 19 2 193 212 0
+p 46 125 0 222 239 1
+p 111 142 1 138 51 1
+p 113 154 2 66 59 0
+p 200 25 3 63 72 3
+p 168 189 2 219 31 3
+p 30 188 1 172 180 3
+p 56 212 1 132 172 1
+p 160 73 0 207 141 1
+p 149 6 0 101 249 2
+p 19 195 3 198 145 3
+p 54 187 4 194 90 2
+p 161 230 0 213 134 1
+p 116 3 1 167 169 2
+p 244 123 1 217 66 3
+p 180 210 3 98 15 0
+p 185 246 1 112 185 3
+p 66 171 1 91 138 3
+p 38 5 3 6 11 1
+p 167 17 0 248 108 4
+p 55 111 1 45 84 4
+p 191 97 2 67 136 3
+p 175 118 0 235 104 1
+p 0 35 4 131 187 0
+p 84 215 4 63 5 4
+p 43 201 3 43 20 4
+p 153 158 2 38 154 1
+p 206 187 0 238 9 0
+p 74 38 1 91 188 2
+p 69 126 1 79 230 2
+p 250 197 2 67 175 2
+p 184 103 2 5 189 0
+p 174 148 3 74 175 1
+p 135 87 4 248 53 2
+p 84 247 4 150 184 3
+p 90 234 4 84 191 0
+p 208 144 4 92 160 1
+p 200 153 4 0 36 0
+p 32 237 4 122 242 4
+p 199 191 0 140 108 4
+p 44 43 3 40 28 2
+p 203 154 3 68 72 2
+p 253 183 4 137 141 4
+p 48 200 3 216 192 0
+p 169 236 2 92 243 2
+p 105 157 4 58 4 2
+p 240 174 3 160 127 3
+p 63 228 1 241 237 0
+p 114 190 2 130 206 3
+p 245 42 4 237 162 4
+p 64 225 3 156 23 0
+p 2 64 3 98 198 3
+p 99 225 0 119 212 0
+p 181 83 0 121 133 0
+p 144 88 0 48 28 2
+p 11 237 4 241 80 4
+p 251 195 1 171 152 2
+p 78 15 0 34 123 3
+p 195 11 4 11 142 3
+p 161 243 1 149 21 2
+p 208 51 1 179 64 1
+p 239 255 0 230 141 0
+p 149 164 0 193 209 0
+p 165 116 1 117 40 1
+p 167 121 2 139 210 1
+p 208 20 2 90 115 4
+p 131 252 4 30 81 0
+p 187 4 4 49 105 0
+p 79 99 0 196 182 1
+p 213 19 0 90 230 3
+p 172 144 4 105 7 4
+p 48 99 1 31 89 0
+p 157 167 0 116 141 4
+p 126 20 0 220 202 4
+p 67 165 0 211 85 4
+p 120 8 4 160 73 0
+p 96 40 2 37 44 4
+p 163 62 4 159 242 2
+p 227 173 0 61 72 0
+p 60 57 4 118 224 0
+p 144 3 4 1 99 4
+p 255 4 4 130 9 3
+p 28 156 3 172 97 0
+p 111 233 1 63 35 2
+p 136 18 2 168 247 2
+p 111 120 1 101 165 1
+p 148 213 4 226 95 0
+p 156 121 1 10 82 3
+p 246 27 4 12 182 0
+p 107 222 1 236 182 3
+p 41 87 2 151 254 1
+p 128 238 1 160 196 3
+p 192 50 4 45 149 1
+p 162 74 2 174 68 3
+p 88 33 3 42 110 1
+p 19 181 3 199 139 2
+p 43 53 1 134 209 1
+p 225 188 3 85 30 4
+p 218 104 4 230 87 2
+p 84 177 4 252 190 1
+p 225 254 1 242 130 4
+p 254 208 3 39 1 2
+p 180 239 2 178 165 1
+p 164 251 0 176 157 1
+p 203 2 4 209 123 0
+p 115 149 1 124 198 4
+p 143 211 0 219 235 0
+p 211 217 4 132 155 1
+p 181 103 0 34 99 4
+p 144 234 4 22 150 1
+p 129 116 2 26 213 2
+p 165 121 0 138 40 4
+p 212 36 0 17 100 4
+p 142 67 1 28 36 4
+p 35 221 4 35 143 0
+p 220 142 3 125 176 4
+p 143 223 1 24 1 1
+p 214 79 1 126 242 2
+p 87 19 2 57 94 1
+p 194 59 4 190 123 4
+p 91 98 0 199 102 2
+p 120 167 1 234 110 1
+p 102 196 4 221 122 1
+p 114 88 1 47 244 2
+p 28 98 1 131 250 4
+p 144 158 3 128 124 1
+p 175 23 1 228 58 4
+p 251 147 0 23 51 1
--- /dev/null
+# Dimensions (x, y, z)
+d 32 32 3
+
+# Paths: Sources (x, y, z) -> Destinations (x, y, z)
+p 27 24 1 8 16 1
+p 25 9 1 18 29 1
+p 9 24 1 8 29 2
+p 25 28 0 23 28 2
+p 15 3 1 19 29 2
+p 15 27 0 25 17 0
+p 23 12 2 21 0 1
+p 27 7 0 27 6 1
+p 7 30 2 14 2 0
+p 16 29 0 17 22 1
+p 26 17 2 19 18 1
+p 19 12 1 9 6 0
+p 19 21 1 2 24 2
+p 29 26 2 29 17 1
+p 22 8 2 27 28 1
+p 30 18 1 21 31 2
+p 25 2 1 15 20 2
+p 7 23 0 7 25 0
+p 26 3 0 22 1 1
+p 29 17 2 0 20 1
+p 18 12 1 31 1 0
+p 30 5 0 6 25 2
+p 0 13 0 8 7 1
+p 11 5 1 1 3 2
+p 6 11 2 26 29 0
+p 21 30 0 21 27 1
+p 8 19 1 5 15 1
+p 18 16 0 11 26 0
+p 17 0 2 10 1 0
+p 7 30 1 9 11 2
+p 20 19 2 12 13 1
+p 0 6 1 7 20 1
+p 28 18 1 12 22 1
+p 21 1 1 8 5 1
+p 15 17 2 28 15 0
+p 14 25 2 25 6 2
+p 20 2 2 31 12 2
+p 10 6 2 0 26 1
+p 3 3 1 27 8 2
+p 3 27 1 2 8 1
+p 25 27 0 16 20 1
+p 27 8 0 1 21 1
+p 30 30 2 1 23 2
+p 20 22 2 20 11 1
+p 6 18 0 4 10 2
+p 22 10 1 1 5 2
+p 9 12 1 9 15 0
+p 1 5 1 2 12 0
+p 13 3 2 15 26 2
+p 10 15 2 13 9 2
+p 28 29 1 12 31 1
+p 2 2 2 1 0 1
+p 16 14 1 18 21 1
+p 11 31 0 24 13 1
+p 2 27 2 28 14 2
+p 3 12 0 1 30 0
+p 4 6 1 17 4 2
+p 31 4 1 21 28 1
+p 29 10 1 15 21 0
+p 19 7 1 30 28 2
+p 1 4 0 25 26 1
+p 22 25 0 2 27 0
+p 7 1 0 27 10 0
+p 4 20 2 16 28 1
--- /dev/null
+# Dimensions (x, y, z)
+d 32 32 3
+
+# Paths: Sources (x, y, z) -> Destinations (x, y, z)
+p 27 24 1 8 16 1
+p 25 9 1 18 29 1
+p 9 24 1 8 29 2
+p 25 28 0 23 28 2
+p 15 3 1 19 29 2
+p 15 27 0 25 17 0
+p 23 12 2 21 0 1
+p 27 7 0 27 6 1
+p 7 30 2 14 2 0
+p 16 29 0 17 22 1
+p 26 17 2 19 18 1
+p 19 12 1 9 6 0
+p 19 21 1 2 24 2
+p 29 26 2 29 17 1
+p 22 8 2 27 28 1
+p 30 18 1 21 31 2
+p 25 2 1 15 20 2
+p 7 23 0 7 25 0
+p 26 3 0 22 1 1
+p 29 17 2 0 20 1
+p 18 12 1 31 1 0
+p 30 5 0 6 25 2
+p 0 13 0 8 7 1
+p 11 5 1 1 3 2
+p 6 11 2 26 29 0
+p 21 30 0 21 27 1
+p 8 19 1 5 15 1
+p 18 16 0 11 26 0
+p 17 0 2 10 1 0
+p 7 30 1 9 11 2
+p 20 19 2 12 13 1
+p 0 6 1 7 20 1
+p 28 18 1 12 22 1
+p 21 1 1 8 5 1
+p 15 17 2 28 15 0
+p 14 25 2 25 6 2
+p 20 2 2 31 12 2
+p 10 6 2 0 26 1
+p 3 3 1 27 8 2
+p 3 27 1 2 8 1
+p 25 27 0 16 20 1
+p 27 8 0 1 21 1
+p 30 30 2 1 23 2
+p 20 22 2 20 11 1
+p 6 18 0 4 10 2
+p 22 10 1 1 5 2
+p 9 12 1 9 15 0
+p 1 5 1 2 12 0
+p 13 3 2 15 26 2
+p 10 15 2 13 9 2
+p 28 29 1 12 31 1
+p 2 2 2 1 0 1
+p 16 14 1 18 21 1
+p 11 31 0 24 13 1
+p 2 27 2 28 14 2
+p 3 12 0 1 30 0
+p 4 6 1 17 4 2
+p 31 4 1 21 28 1
+p 29 10 1 15 21 0
+p 19 7 1 30 28 2
+p 1 4 0 25 26 1
+p 22 25 0 2 27 0
+p 7 1 0 27 10 0
+p 4 20 2 16 28 1
+p 18 21 2 24 31 2
+p 28 6 1 19 26 1
+p 25 12 1 27 25 1
+p 0 5 1 8 2 2
+p 30 9 1 25 1 1
+p 4 9 2 1 1 1
+p 15 27 2 21 4 2
+p 13 19 1 1 15 0
+p 1 19 1 3 17 1
+p 12 24 1 28 19 1
+p 20 10 0 21 19 2
+p 4 29 2 29 27 2
+p 25 16 2 6 25 1
+p 24 14 2 2 1 2
+p 15 28 2 21 18 0
+p 2 26 2 24 22 1
+p 9 3 1 18 29 2
+p 13 3 2 23 0 1
+p 21 0 2 30 23 0
+p 2 11 0 11 0 2
+p 26 2 2 6 6 2
+p 30 3 0 11 0 1
+p 27 5 0 11 30 0
+p 30 11 1 9 29 2
+p 20 5 2 3 18 0
+p 28 30 2 10 7 2
+p 9 13 0 4 0 0
+p 2 13 1 23 4 1
+p 20 2 1 11 30 0
+p 13 13 2 10 6 0
+p 15 30 2 8 17 2
+p 25 14 1 24 13 0
--- /dev/null
+# Dimensions (x, y, z)
+d 48 48 3
+
+# Paths: Sources (x, y, z) -> Destinations (x, y, z)
+p 40 36 1 12 24 1
+p 37 14 1 28 43 1
+p 13 36 1 12 43 2
+p 38 43 0 35 43 2
+p 22 4 1 29 43 2
+p 22 41 0 38 26 0
+p 34 19 2 32 0 1
+p 41 11 0 41 9 1
+p 11 46 2 21 3 0
+p 24 44 0 26 33 1
+p 39 25 2 28 28 1
+p 28 18 1 13 9 0
+p 29 31 1 4 36 2
+p 44 40 2 44 25 1
+p 33 13 2 40 42 1
+p 45 27 1 31 47 2
+p 38 3 1 23 30 2
+p 11 35 0 10 38 0
+p 39 4 0 33 2 1
+p 43 25 2 1 30 1
+p 27 18 1 47 1 0
+p 46 8 0 10 38 2
+p 1 20 0 12 10 1
+p 16 8 1 1 4 2
+p 9 17 2 40 44 0
+p 32 46 0 32 40 1
+p 12 28 1 8 22 1
+p 27 24 0 17 40 0
+p 26 0 2 16 2 0
+p 11 45 1 13 17 2
+p 30 29 2 18 19 1
+p 0 9 1 11 30 1
+p 42 27 1 19 33 1
+p 31 2 1 12 7 1
+p 23 26 2 42 23 0
+p 22 38 2 38 9 2
+p 30 4 2 47 19 2
+p 15 10 2 0 39 1
+p 4 5 1 41 13 2
+p 4 40 1 3 13 1
+p 38 41 0 25 31 1
+p 41 13 0 1 32 1
+p 45 45 2 2 35 2
+p 31 34 2 30 17 1
+p 9 28 0 7 16 2
+p 34 16 1 1 7 2
+p 13 18 1 14 22 0
+p 2 8 1 3 19 0
--- /dev/null
+# Dimensions (x, y, z)
+d 48 48 3
+
+# Paths: Sources (x, y, z) -> Destinations (x, y, z)
+p 40 36 1 12 24 1
+p 37 14 1 28 43 1
+p 13 36 1 12 43 2
+p 38 43 0 35 43 2
+p 22 4 1 29 43 2
+p 22 41 0 38 26 0
+p 34 19 2 32 0 1
+p 41 11 0 41 9 1
+p 11 46 2 21 3 0
+p 24 44 0 26 33 1
+p 39 25 2 28 28 1
+p 28 18 1 13 9 0
+p 29 31 1 4 36 2
+p 44 40 2 44 25 1
+p 33 13 2 40 42 1
+p 45 27 1 31 47 2
+p 38 3 1 23 30 2
+p 11 35 0 10 38 0
+p 39 4 0 33 2 1
+p 43 25 2 1 30 1
+p 27 18 1 47 1 0
+p 46 8 0 10 38 2
+p 1 20 0 12 10 1
+p 16 8 1 1 4 2
+p 9 17 2 40 44 0
+p 32 46 0 32 40 1
+p 12 28 1 8 22 1
+p 27 24 0 17 40 0
+p 26 0 2 16 2 0
+p 11 45 1 13 17 2
+p 30 29 2 18 19 1
+p 0 9 1 11 30 1
+p 42 27 1 19 33 1
+p 31 2 1 12 7 1
+p 23 26 2 42 23 0
+p 22 38 2 38 9 2
+p 30 4 2 47 19 2
+p 15 10 2 0 39 1
+p 4 5 1 41 13 2
+p 4 40 1 3 13 1
+p 38 41 0 25 31 1
+p 41 13 0 1 32 1
+p 45 45 2 2 35 2
+p 31 34 2 30 17 1
+p 9 28 0 7 16 2
+p 34 16 1 1 7 2
+p 13 18 1 14 22 0
+p 2 8 1 3 19 0
+p 19 4 2 22 40 2
+p 16 22 2 20 14 2
+p 42 44 1 18 46 1
+p 3 4 2 2 0 1
+p 24 21 1 28 32 1
+p 17 47 0 37 20 1
+p 3 41 2 43 21 2
+p 5 19 0 2 45 0
+p 7 9 1 26 7 2
+p 47 7 1 32 42 1
+p 44 15 1 23 32 0
+p 29 10 1 46 43 2
+p 1 7 0 37 40 1
+p 34 38 0 4 41 0
+p 10 1 0 40 15 0
+p 7 31 2 24 43 1
--- /dev/null
+# Dimensions (x, y, z)
+d 512 512 7
+
+# Paths: Sources (x, y, z) -> Destinations (x, y, z)
+p 432 388 2 132 261 2
+p 401 155 3 298 464 3
+p 144 386 4 128 465 6
+p 414 461 2 373 460 4
+p 241 51 3 312 467 6
+p 244 443 1 412 280 0
+p 368 204 5 342 0 3
+p 444 124 2 445 97 3
+p 122 495 5 229 41 2
+p 260 477 0 282 361 3
+p 417 276 6 308 300 3
+p 305 197 4 148 96 1
+p 313 336 3 45 387 6
+p 472 431 6 472 276 2
+p 361 141 5 434 458 4
+p 486 296 3 338 510 6
+p 406 42 4 249 322 5
+p 124 374 0 112 406 2
+p 417 51 1 357 23 4
+p 465 273 4 13 325 4
+p 294 200 2 502 18 0
+p 492 94 0 107 409 6
+p 11 217 0 133 113 4
+p 179 92 3 20 51 6
+p 102 183 5 429 470 1
+p 344 494 0 346 432 2
+p 128 305 3 89 241 2
+p 291 260 2 182 428 1
+p 287 6 5 171 23 1
+p 122 488 2 147 183 6
+p 324 317 5 198 212 4
+p 0 98 2 122 326 2
+p 448 290 2 205 359 2
+p 339 23 3 132 80 3
+p 249 287 5 452 253 2
+p 239 414 6 415 96 6
+p 324 42 5 505 205 4
+p 161 109 5 1 421 3
+p 50 60 4 447 143 6
+p 51 437 2 41 140 3
+p 405 441 0 266 333 2
+p 446 142 0 20 348 3
+p 484 480 6 21 383 4
+p 335 364 6 327 190 3
+p 106 300 0 77 170 5
+p 367 173 4 21 83 6
+p 148 202 3 150 244 1
+p 24 91 3 36 206 2
+p 212 50 6 242 430 6
+p 175 245 4 218 154 5
+p 457 470 4 192 498 4
+p 33 43 5 31 4 2
+p 265 229 3 299 347 2
+p 188 506 1 397 220 2
+p 32 442 4 462 231 4
+p 60 203 1 21 485 1
+p 74 101 2 279 77 6
+p 503 75 2 348 449 3
+p 469 165 3 255 343 1
+p 312 112 2 492 460 5
+p 18 75 1 401 431 4
+p 367 413 0 43 444 0
+p 115 20 0 432 169 1
+p 76 335 6 258 461 3
+p 293 347 5 388 507 5
+p 463 105 3 306 422 3
+p 405 198 4 435 408 4
+p 0 93 3 130 33 6
+p 482 155 2 414 31 4
+p 65 146 5 28 18 2
+p 251 442 5 344 77 6
+p 210 313 2 24 241 1
+p 16 316 4 53 281 2
+p 196 397 3 451 312 3
+p 323 172 0 349 318 5
+p 65 466 5 469 446 4
+p 414 265 5 96 400 3
+p 387 233 5 38 22 6
+p 248 461 6 341 292 1
+p 47 419 6 399 357 2
+p 156 58 2 289 472 6
+p 212 50 5 375 15 3
+p 351 15 6 492 369 0
+p 36 183 0 178 5 6
+p 419 36 6 106 104 4
+p 480 63 0 188 12 4
+p 439 95 0 176 491 0
+p 494 185 3 149 479 6
+p 325 94 6 52 297 1
+p 459 484 5 161 124 5
+p 149 214 0 67 10 0
+p 37 215 3 379 72 2
+p 326 43 3 189 485 0
+p 209 213 5 164 104 2
+p 241 486 5 141 285 4
+p 407 228 2 393 221 1
+p 232 479 0 236 326 3
+p 104 0 4 316 3 2
+p 393 322 3 79 361 3
+p 347 389 1 390 143 6
+p 61 452 0 131 269 4
+p 202 52 1 145 386 6
+p 304 18 5 156 174 3
+p 127 471 1 212 148 3
+p 293 321 3 210 324 2
+p 398 403 2 190 321 1
+p 356 195 4 71 342 2
+p 242 212 3 355 162 4
+p 30 153 5 26 318 0
+p 241 454 0 269 34 6
+p 351 379 4 3 21 4
+p 511 447 4 372 116 5
+p 147 53 3 169 86 2
+p 459 222 3 362 268 0
+p 466 227 5 199 413 2
+p 112 100 6 300 25 2
+p 119 43 1 29 326 1
+p 312 313 4 262 145 6
+p 180 234 4 264 489 6
+p 476 478 4 250 360 1
+p 136 22 1 1 335 0
+p 402 348 6 203 471 3
+p 173 52 6 406 165 3
+p 166 14 0 188 107 3
+p 96 103 4 376 159 6
+p 130 176 4 22 478 0
+p 235 370 0 414 501 3
+p 60 41 0 391 211 6
+p 225 39 2 386 424 0
+p 92 250 0 445 478 2
+p 222 285 1 277 103 2
+p 226 309 3 133 118 0
+p 401 50 5 127 145 5
+p 337 379 3 439 62 4
+p 60 377 2 345 360 4
+p 113 425 1 265 345 1
+p 321 146 1 414 283 2
+p 299 12 0 202 499 3
+p 39 391 5 396 291 4
+p 109 375 5 389 180 4
+p 322 461 0 426 269 2
+p 233 6 1 334 338 3
+p 488 246 2 434 132 4
+p 360 420 5 196 30 0
+p 371 492 2 225 371 4
+p 133 343 2 182 276 5
+p 77 11 4 12 23 1
+p 334 34 0 497 216 6
+p 110 222 2 90 168 6
+p 382 195 2 135 272 5
+p 351 236 0 471 209 2
+p 1 70 6 263 375 1
+p 168 430 5 126 11 5
+p 86 403 4 86 40 6
+p 306 317 3 76 308 1
+p 412 375 0 477 18 0
+p 149 77 1 182 376 2
+p 138 252 2 159 461 3
+p 500 395 3 134 351 3
+p 369 206 3 10 378 0
+p 348 297 5 148 351 1
+p 270 174 6 497 106 3
+p 168 495 6 300 368 4
+p 180 469 6 169 382 0
+p 417 289 6 185 320 2
+p 400 307 6 0 72 0
+p 64 475 6 245 484 5
+p 398 382 1 281 217 6
+p 89 86 4 80 56 3
+p 407 309 5 136 145 3
+p 507 367 6 275 283 6
+p 97 400 5 432 384 1
+p 338 472 3 184 486 3
+p 210 314 5 116 8 3
+p 481 348 4 321 254 5
+p 127 456 1 483 474 0
+p 229 380 3 260 413 4
+p 490 84 6 475 324 6
+p 129 451 5 312 46 0
+p 5 128 5 197 397 4
+p 199 450 0 238 424 0
+p 363 167 0 242 267 0
+p 289 177 0 97 56 3
+p 22 475 5 483 161 6
+p 503 391 1 343 304 2
+p 156 30 0 68 246 4
+p 391 23 5 22 284 5
+p 323 486 2 299 42 3
+p 416 103 1 358 129 1
+p 478 511 1 460 282 0
+p 299 328 0 387 418 0
+p 331 233 1 234 81 2
+p 335 243 3 278 420 2
+p 416 40 2 180 231 5
+p 262 505 6 60 162 0
+p 375 9 6 98 211 0
+p 159 199 0 392 364 2
+p 427 39 0 181 461 5
+p 344 288 5 211 15 5
+p 97 198 2 63 179 1
+p 315 334 0 233 283 6
+p 253 41 0 441 404 6
+p 134 331 0 423 170 6
+p 241 16 6 320 146 0
+p 192 80 3 75 89 6
+p 327 124 6 319 484 3
+p 454 347 0 123 144 1
+p 121 115 6 237 448 0
+p 289 6 6 2 199 5
+p 511 9 5 261 19 5
+p 57 313 5 344 194 0
+p 223 467 2 126 70 3
+p 273 37 2 337 494 3
+p 223 241 1 202 330 2
+p 297 427 6 453 190 0
+p 313 242 1 20 164 5
+p 493 54 6 24 365 0
+p 215 445 2 473 365 4
+p 82 174 2 302 509 1
+p 257 477 2 321 392 4
+p 385 100 6 90 298 2
+p 324 149 3 349 137 5
+p 177 67 4 84 220 2
+p 38 363 4 398 278 3
+p 86 106 1 268 419 2
+p 451 376 5 171 60 6
+p 437 209 6 460 175 3
+p 169 355 6 504 380 2
+p 450 508 2 485 261 6
+p 509 416 4 78 2 4
+p 360 478 3 356 331 1
+p 329 502 0 352 314 2
+p 406 5 6 418 246 0
+p 231 299 1 249 397 6
+p 287 423 0 438 471 1
+p 423 434 6 264 311 1
+p 362 207 0 68 198 6
+p 289 469 6 44 301 2
+p 259 233 3 52 426 3
+p 330 242 1 276 81 5
+p 425 73 0 35 201 6
+p 284 135 1 56 72 5
+p 70 442 5 70 286 0
+p 441 285 5 251 353 6
+p 286 447 2 49 2 1
+p 429 159 1 253 484 3
+p 174 39 4 115 188 2
+p 388 118 6 380 246 6
+p 183 196 0 398 205 3
+p 241 335 2 468 221 2
+p 205 392 6 443 245 2
+p 228 176 1 95 489 3
+p 56 196 2 262 501 6
+p 289 316 4 257 249 2
+p 350 47 2 456 116 6
+p 503 294 0 47 102 2
+p 57 408 2 119 22 2
+p 2 59 4 478 102 5
+p 101 0 6 433 34 1
+p 119 475 2 413 223 2
+p 391 315 1 298 360 5
+p 346 328 4 47 483 5
+p 139 354 4 337 194 4
+p 337 103 3 61 54 6
+p 63 457 3 232 173 2
+p 193 289 2 420 119 1
+p 246 478 0 370 3 2
+p 391 228 3 129 243 1
+p 145 334 4 475 496 3
+p 44 153 3 344 484 1
+p 18 445 5 392 239 4
+p 210 98 2 402 410 6
+p 454 349 3 370 93 6
+p 364 304 3 324 316 6
+p 292 109 3 124 463 5
+p 284 100 0 68 226 4
+p 114 350 6 387 217 4
+p 506 453 2 350 83 3
+p 182 224 3 339 433 3
+p 75 386 5 488 201 3
+p 276 456 4 10 106 5
+p 299 447 2 107 2 6
+p 69 329 3 194 275 0
+p 496 252 0 214 387 2
+p 381 392 1 495 14 6
+p 262 78 1 303 142 5
+p 112 196 3 173 421 1
+p 45 79 4 288 32 6
+p 245 163 5 12 222 4
+p 492 389 6 60 220 0
+p 139 196 2 191 411 1
+p 422 277 2 282 82 3
+p 11 441 2 176 509 4
+p 213 404 0 292 266 6
+p 300 248 3 400 177 3
+p 362 509 4 492 204 4
+p 381 178 1 498 178 6
+p 436 110 5 503 141 4
+p 394 42 5 157 361 6
+p 17 313 2 58 364 6
+p 262 177 3 212 272 2
+p 41 501 6 89 123 3
+p 357 16 5 326 137 6
+p 338 162 3 501 24 4
+p 434 354 0 305 402 2
+p 298 129 2 413 250 3
+p 62 191 3 118 413 2
+p 122 157 5 462 491 0
+p 385 269 0 126 144 2
+p 241 479 0 363 437 2
+p 127 113 2 74 282 1
+p 13 119 5 213 452 6
+p 124 286 6 297 86 1
+p 505 153 6 407 379 5
+p 404 433 0 85 258 1
+p 273 252 0 44 5 5
+p 41 492 6 381 230 1
+p 211 176 2 371 456 1
+p 124 107 0 437 261 0
+p 228 230 5 389 68 4
+p 260 6 1 341 187 6
+p 256 352 0 245 375 5
+p 102 203 3 225 243 2
+p 414 467 2 326 194 4
+p 356 256 4 387 431 1
+p 110 263 3 413 264 6
+p 398 259 5 243 174 3
+p 233 333 0 373 495 3
+p 35 103 0 131 406 0
+p 447 481 1 88 494 2
+p 415 4 6 8 311 6
+p 425 158 5 201 255 2
+p 181 298 5 358 393 0
+p 272 180 1 471 100 1
+p 91 336 4 258 300 6
+p 440 463 0 459 16 4
+p 476 257 2 169 469 6
+p 316 365 2 70 501 4
+p 140 500 4 169 458 0
+p 411 81 0 132 365 4
+p 215 81 6 392 351 5
+p 396 57 5 429 382 3
+p 351 51 5 134 401 4
+p 260 274 0 20 7 5
+p 70 62 2 500 453 2
+p 419 43 2 296 504 0
+p 211 470 0 306 204 3
+p 360 208 6 489 504 0
+p 428 449 1 482 65 1
+p 489 425 4 147 129 2
+p 4 325 0 396 35 0
+p 145 395 5 259 480 0
+p 170 379 2 74 296 0
+p 190 129 2 248 274 0
+p 161 196 2 245 218 0
+p 112 329 5 261 75 0
+p 79 196 3 340 268 3
+p 180 340 5 205 417 5
+p 463 238 2 397 19 2
+p 500 175 3 127 39 0
+p 222 316 3 265 57 0
+p 183 482 1 137 247 6
+p 484 0 4 120 335 5
+p 454 349 5 401 82 0
+p 378 269 6 84 197 2
+p 449 247 6 362 511 4
+p 499 88 3 296 500 3
+p 443 321 3 200 188 2
+p 108 492 3 443 453 6
+p 121 172 4 164 73 5
+p 281 274 4 58 472 3
+p 354 307 4 363 45 3
+p 107 199 3 181 208 5
+p 22 489 4 83 285 0
+p 256 352 2 160 344 6
+p 447 197 6 58 30 6
+p 390 314 3 158 460 5
+p 246 112 4 371 509 5
+p 46 506 5 298 169 5
+p 305 49 3 10 403 5
+p 373 46 4 200 65 6
+p 482 472 3 442 101 2
+p 465 302 1 66 116 3
+p 155 376 1 40 459 4
+p 498 93 6 8 275 3
+p 64 417 1 459 358 5
+p 443 405 5 2 73 1
+p 295 1 0 248 21 2
+p 112 89 2 451 118 4
+p 375 345 1 179 139 3
+p 496 111 3 33 192 6
+p 465 48 5 366 469 3
+p 216 458 3 389 90 0
+p 225 167 3 176 441 5
+p 196 64 4 277 77 0
+p 315 264 4 212 239 2
+p 44 274 0 344 383 1
+p 103 123 4 208 454 3
+p 269 111 0 473 51 0
+p 99 295 4 220 202 4
+p 134 409 4 308 14 2
+p 393 105 4 499 225 3
+p 108 3 1 241 309 5
+p 148 168 5 340 365 6
+p 45 63 3 313 334 1
+p 69 471 1 9 144 3
+p 324 378 1 260 163 5
+p 184 415 1 509 266 2
+p 371 193 0 225 147 4
+p 269 425 3 79 76 4
+p 135 108 6 71 469 3
+p 479 429 2 240 43 2
+p 474 51 1 21 440 4
+p 301 238 1 299 359 5
+p 83 320 4 297 372 3
+p 488 332 4 6 73 4
+p 392 73 4 79 390 5
+p 317 34 1 138 239 5
+p 296 507 4 72 501 0
+p 170 326 2 11 151 1
+p 397 303 1 446 109 2
+p 447 391 2 265 501 4
+p 366 335 6 473 152 3
+p 325 121 4 462 156 2
+p 230 197 4 26 397 1
+p 318 217 4 291 264 1
+p 3 54 2 131 248 3
+p 263 67 3 486 88 0
+p 173 362 6 55 15 2
+p 318 471 2 399 65 4
+p 127 389 6 226 351 2
+p 434 209 4 505 285 3
+p 49 486 3 358 335 1
+p 326 49 0 430 307 2
+p 269 285 4 0 73 0
+p 385 231 1 191 342 3
+p 279 480 2 52 54 5
+p 159 58 5 455 52 4
+p 379 125 5 350 227 1
+p 132 424 1 360 292 3
+p 8 62 2 322 195 1
+p 196 237 4 286 188 2
+p 412 301 6 308 145 3
+p 242 436 5 450 367 1
+p 139 83 6 460 165 0
+p 242 403 4 345 10 0
+p 373 419 1 417 487 4
+p 282 16 2 239 488 3
+p 6 290 0 507 337 5
+p 355 481 2 142 40 0
+p 244 380 5 1 315 5
+p 443 394 2 360 359 0
+p 19 177 4 195 330 5
+p 394 144 6 283 321 4
+p 344 78 4 220 495 4
+p 498 507 5 300 307 3
+p 189 214 6 330 87 0
+p 224 225 0 116 169 2
+p 319 79 5 254 35 0
+p 482 16 4 91 334 6
+p 470 223 3 148 225 6
+p 19 245 6 54 59 5
+p 144 408 2 16 419 2
+p 236 30 4 424 112 6
+p 324 280 1 448 217 0
+p 473 188 2 29 16 0
+p 447 444 3 41 71 6
+p 287 407 0 33 397 0
+p 420 478 3 58 367 3
+p 256 454 3 70 190 5
+p 261 41 3 17 450 1
+p 373 509 6 270 165 4
+p 279 465 1 355 78 2
+p 398 186 1 180 191 0
+p 73 379 4 334 70 0
+p 250 247 0 494 418 6
+p 88 336 5 165 504 0
+p 406 74 1 97 59 4
+p 124 409 5 490 396 6
+p 285 16 2 201 494 2
+p 138 409 6 23 502 5
+p 509 332 0 347 116 6
+p 477 440 4 129 474 5
+p 324 87 1 290 303 2
+p 416 347 1 15 310 2
+p 455 119 3 101 494 4
+p 385 456 3 279 230 4
+p 171 420 2 394 8 2
+p 245 461 5 375 325 6
+p 371 323 6 391 7 6
+p 96 383 2 200 78 3
+p 511 423 5 329 109 0
+p 477 465 0 466 383 0
+p 78 90 1 462 215 3
+p 217 237 1 161 129 1
+p 311 11 6 263 257 2
+p 374 389 5 494 212 0
+p 408 364 0 252 414 6
+p 179 241 3 380 360 3
+p 94 300 0 182 157 0
+p 49 403 3 65 478 2
+p 225 355 1 400 432 3
+p 363 370 6 396 184 3
+p 201 273 6 49 457 3
+p 74 478 1 13 241 4
+p 25 321 3 288 41 2
+p 66 239 2 168 451 4
+p 56 336 6 187 394 4
+p 243 207 1 213 136 3
+p 342 454 1 414 390 4
+p 98 36 0 164 149 5
+p 175 83 6 360 411 3
--- /dev/null
+# Dimensions (x, y, z)
+d 64 64 3
+
+# Paths: Sources (x, y, z) -> Destinations (x, y, z)
+p 54 48 1 16 32 1
+p 50 19 1 37 58 1
+p 18 48 1 16 58 2
+p 51 57 0 46 57 2
+p 30 6 1 39 58 2
+p 30 55 0 51 35 0
+p 46 25 2 42 0 1
+p 55 15 0 55 12 1
+p 15 61 2 28 5 0
+p 32 59 0 35 45 1
+p 52 34 2 38 37 1
+p 38 24 1 18 12 0
+p 39 42 1 5 48 2
+p 59 53 2 59 34 1
+p 45 17 2 54 57 1
+p 60 37 1 42 63 2
+p 50 5 1 31 40 2
+p 15 46 0 14 50 0
+p 52 6 0 44 2 1
+p 58 34 2 1 40 1
+p 36 25 1 62 2 0
+p 61 11 0 13 51 2
+p 1 27 0 16 14 1
+p 22 11 1 2 6 2
+p 12 22 2 53 58 0
+p 43 61 0 43 54 1
+p 16 38 1 11 30 1
+p 36 32 0 22 53 0
+p 35 0 2 21 2 0
+p 15 61 1 18 22 2
+p 40 39 2 24 26 1
+p 0 12 1 15 40 1
+p 56 36 1 25 44 1
+p 42 2 1 16 10 1
+p 31 35 2 56 31 0
+p 29 51 2 51 12 2
+p 40 5 2 63 25 2
+p 20 13 2 0 52 1
+p 6 7 1 55 17 2
+p 6 54 1 5 17 1
+p 50 55 0 33 41 1
+p 55 17 0 2 43 1
+p 60 60 2 2 47 2
+p 41 45 2 40 23 1
+p 13 37 0 9 21 2
+p 45 21 1 2 10 2
+p 18 25 1 18 30 0
+p 3 11 1 4 25 0
--- /dev/null
+# Dimensions (x, y, z)
+d 64 64 3
+
+# Paths: Sources (x, y, z) -> Destinations (x, y, z)
+p 54 48 1 16 32 1
+p 50 19 1 37 58 1
+p 18 48 1 16 58 2
+p 51 57 0 46 57 2
+p 30 6 1 39 58 2
+p 30 55 0 51 35 0
+p 46 25 2 42 0 1
+p 55 15 0 55 12 1
+p 15 61 2 28 5 0
+p 32 59 0 35 45 1
+p 52 34 2 38 37 1
+p 38 24 1 18 12 0
+p 39 42 1 5 48 2
+p 59 53 2 59 34 1
+p 45 17 2 54 57 1
+p 60 37 1 42 63 2
+p 50 5 1 31 40 2
+p 15 46 0 14 50 0
+p 52 6 0 44 2 1
+p 58 34 2 1 40 1
+p 36 25 1 62 2 0
+p 61 11 0 13 51 2
+p 1 27 0 16 14 1
+p 22 11 1 2 6 2
+p 12 22 2 53 58 0
+p 43 61 0 43 54 1
+p 16 38 1 11 30 1
+p 36 32 0 22 53 0
+p 35 0 2 21 2 0
+p 15 61 1 18 22 2
+p 40 39 2 24 26 1
+p 0 12 1 15 40 1
+p 56 36 1 25 44 1
+p 42 2 1 16 10 1
+p 31 35 2 56 31 0
+p 29 51 2 51 12 2
+p 40 5 2 63 25 2
+p 20 13 2 0 52 1
+p 6 7 1 55 17 2
+p 6 54 1 5 17 1
+p 50 55 0 33 41 1
+p 55 17 0 2 43 1
+p 60 60 2 2 47 2
+p 41 45 2 40 23 1
+p 13 37 0 9 21 2
+p 45 21 1 2 10 2
+p 18 25 1 18 30 0
+p 3 11 1 4 25 0
+p 26 6 2 30 53 2
+p 21 30 2 27 19 2
+p 57 58 1 24 62 1
+p 4 5 2 3 0 1
+p 33 28 1 37 43 1
+p 23 63 0 49 27 1
+p 4 55 2 57 28 2
+p 7 25 0 2 60 0
+p 9 12 1 34 9 2
+p 62 9 1 43 56 1
+p 58 20 1 31 42 0
+p 39 14 1 61 57 2
+p 2 9 0 50 53 1
+p 45 51 0 5 55 0
+p 14 2 0 54 21 0
+p 9 41 2 32 57 1
--- /dev/null
+MAINCLASS=Labyrinth
+SRC=ttttmp${MAINCLASS}.java \
+ ../common/Pair.java \
+ ttttmpQueue_t.java \
+ ttttmpQueue_Int.java \
+ Vector_t.java \
+ List_t.java \
+ List_Node.java \
+ List_Iter.java \
+ Coordinate.java \
+ ttttmpGrid.java \
+ ttttmpMaze.java \
+ ttttmpRouter.java \
+ Point.java \
+ Solve_arg.java \
+ ../../../ClassLibrary/JavaSTM/Barrier.java
+
+include ../common/Makefile.flags
+
+include ../common/Makefile.builds
+
+prep:
+ cpp ${MAINCLASS}.java > tmp${MAINCLASS}.java
+ cpp Grid.java > tmpGrid.java
+ cpp Router.java > tmpRouter.java
+ cpp Maze.java > tmpMaze.java
+ cpp Queue_t.java > tmpQueue_t.java
+ cpp Queue_Int.java > tmpQueue_Int.java
+ ./extractLines tmp${MAINCLASS}.java
+ ./extractLines tmpGrid.java
+ ./extractLines tmpRouter.java
+ ./extractLines tmpMaze.java
+ ./extractLines tmpQueue_t.java
+ ./extractLines tmpQueue_Int.java
+
+
+clean:
+ rm -rf tmpbuilddirectory
+ rm *.bin
+
+test:
+ cpp ${MAINCLASS}.java > tmp${MAINCLASS}.java
+ cpp Grid.java > tmpGrid.java
+ cpp Router.java > tmpRouter.java
+ cpp Maze.java > tmpMaze.java
+ cpp Queue_t.java > tmpQueue_t.java
+ cpp Queue_Int.java > tmpQueue_Int.java
+ ./extractLines tmp${MAINCLASS}.java
+ ./extractLines tmpGrid.java
+ ./extractLines tmpRouter.java
+ ./extractLines tmpMaze.java
+ ./extractLines tmpQueue_t.java
+ ./extractLines tmpQueue_Int.java
+ ../../../buildscript ${FLAGS} -o ${MAINCLASS} ${SRC}
+ rm ttt*.java tmp*.java
+ ./Labyrinth.bin -i inputs/random-x32-y32-z3-n64.txt