Example #1
0
        private static void testCompressor()
        {
            int[]          size3D          = { 3, 6, 6 }; // (z,y,x)
            IMazeGenerator mazeGenerator3d = new MyMaze3dGenerator();
            Maze3d         maze            = (Maze3d)mazeGenerator3d.generate(size3D);

            maze.print();
            Console.ReadKey();
            byte[] decomp = maze.toByteArray();
            for (int i = 0; i < decomp.Length; i++)
            {
                Console.Write(decomp[i] + " ");
            }
            ICompressor compressor = new MyMaze3DCompressor();

            Console.WriteLine("\ncompression : ");
            byte[] comp = compressor.compress(decomp);
            for (int i = 0; i < comp.Length; i++)
            {
                Console.Write(comp[i] + " ");
            }
            decomp = compressor.decompress(comp);
            Console.WriteLine("\ndecompression : ");
            for (int i = 0; i < decomp.Length; i++)
            {
                Console.Write(decomp[i] + " ");
            }
        }
Example #2
0
        private static void testMeze3dGenerator(MyMaze3dGenerator mg)
        {
            ArrayList s = new ArrayList();

            s.Add(20);
            s.Add(20);
            s.Add(4);

            Console.WriteLine(mg.MeasureAlgorithmTime(s));
            AMaze    maze  = mg.generate(s);
            Position start = maze.getStartPosition();

            start.print();
            maze.getGoalPosition().print();
            maze.Print();
            byte[]      dar  = (maze as Maze3d).toByteArray();
            Maze3d      hara = new Maze3d(dar);
            ICompressor car  = new MyMaze3DCompressor();

            byte[] hara1 = car.compress(dar);
            byte[] hara2 = car.decompress(hara1);
            Maze3d hara3 = new Maze3d(hara2);

            hara3.Print();


            /*using (FileStream fileOutStream = new FileStream("1.maze", FileMode.Create))
             * {
             *  using (Stream outStream = new MyCompressorStream(fileOutStream, 1))
             *  {
             *      outStream.Write((maze as Maze3d).toByteArray(),0,1);
             *      outStream.Flush();
             *  }
             * }
             * byte[] mazeBytes;
             * using (FileStream fileInStream = new FileStream("1.maze", FileMode.Open))
             * {
             *  using (Stream inStream = new MyCompressorStream(fileInStream,1))
             *  {
             *      mazeBytes = new byte[(maze as Maze3d).toByteArray().Count()];
             *      input.read(b);
             *  }
             * }
             * Maze3d loadedMaze = new Maze3d(mazeBytes);
             * System.out.println(loaded.equals(maze));*/



            Console.ReadKey();
        }
Example #3
0
        private static void TestCheck()
        {
            IMazeGenerator     mg   = new MyMaze3dGenerator();
            Maze               maze = mg.generate(8, 8, 5);
            MyMaze3DCompressor comp = new MyMaze3DCompressor();

            byte[] byteArray = ((Maze3d)maze).toByteArray();
            Console.WriteLine("Before");
            for (int i = 0; i < byteArray.Length; i++)
            {
                Console.Write(byteArray[i]);
            }
            Console.WriteLine();
            Console.WriteLine("After");
            byte[] byteArrayAfter    = comp.compress(byteArray);
            byte[] byteArrayAfterDec = comp.decompress(byteArrayAfter);
            for (int i = 0; i < byteArrayAfterDec.Length; i++)
            {
                Console.Write(byteArrayAfterDec[i]);
            }
            Console.WriteLine();
        }