예제 #1
0
        private void button23_Click(object sender, EventArgs e)
        {
            Task.Run(new Action(() =>
            {

                Algorithm curalg = new AlgorithmBacktrack();
                InnerMapType innerMapType = InnerMapType.BitArreintjeFast;

                Stopwatch w = new Stopwatch();
                w.Start();
                int size = 2048 * 8;
                DebugMSG("Generating maze of size: " + size);
                DebugMSG("Current algorithm: " + curalg.ToString());
                DebugMSG("Current InnerMapType: " + innerMapType.ToString());
                DebugMSG("Saved size it should be: " + Math.Pow((double)size, 2.0) / 1024.0 / 1024.0 / 8.0 + " mb");
                DebugMSG("Or in GB: " + Math.Pow((double)size, 2.0) / 1024.0 / 1024.0 / 1024.0 / 8.0 + " gb");
                Maze maze = curalg.Generate(size, size, innerMapType, 1337, (x, y, cur, tot) =>
                {
                    curXInMaze = x;
                    curYInMaze = y;
                    currentStepsToCalcPercentage = cur;
                    totalStepsToCalcPercentage = tot;
                });

                w.Stop();
                DebugMSG("Generating time: " + w.Elapsed.TotalSeconds);
                //DebugMSG("Finding Path...");
                //w.Reset();
                //w.Start();
                //var path = PathFinderDepthFirstSmart.GoFind(maze.InnerMap, null);
                //w.Stop();
                //DebugMSG("Done generating path: " + w.Elapsed.TotalSeconds);
                //DebugMSG("Saving...");
                //w.Reset();
                //w.Start();
                //maze.SaveMazeAsImage("benchmark 16k single core.png", ImageFormat.Png, path, MazeSaveType.ColorDepth32Bits);
                //w.Stop();
                //DebugMSG("Done saving: " + w.Elapsed.TotalSeconds);
            }));
        }
예제 #2
0
        private void button34_Click(object sender, EventArgs e)
        {
            Task.Run(new Action(() =>
            {

                Algorithm curalg = new AlgorithmBacktrack();
                InnerMapType innerMapType = InnerMapType.BitArreintjeFast;

                Stopwatch w = new Stopwatch();
                w.Start();
                int size = 2048 * 8;
                DebugMSG("Generating maze of size: " + size);
                DebugMSG("Current algorithm: " + curalg.ToString());
                DebugMSG("Current InnerMapType: " + innerMapType.ToString());
                DebugMSG("Saved size it should be: " + Math.Pow((double)size, 2.0) / 1024.0 / 1024.0 / 8.0 + " mb");
                DebugMSG("Or in GB: " + Math.Pow((double)size, 2.0) / 1024.0 / 1024.0 / 1024.0 / 8.0 + " gb");
                Maze maze = curalg.Generate(size, size, innerMapType, 1337, (x, y, cur, tot) =>
                {
                    curXInMaze = x;
                    curYInMaze = y;
                    currentStepsToCalcPercentage = cur;
                    totalStepsToCalcPercentage = tot;
                });

                w.Stop();
                DebugMSG("Generating time: " + w.Elapsed.TotalSeconds);

                DebugMSG("Finding Path...");
                w.Reset();
                w.Start();
                var path = PathFinderDepthFirst.GoFind(maze.InnerMap, null);
                w.Stop();
                DebugMSG("PathFinderDepthFirst: " + w.Elapsed.TotalSeconds);

                w.Reset();
                w.Start();
                var path2 = PathFinderDepthFirstSmart.GoFind(maze.InnerMap, null);
                w.Stop();
                DebugMSG("PathFinderDepthFirstSmart: " + w.Elapsed.TotalSeconds);

                DebugMSG("Comparing paths to be sure they match...");
                if (path.Count != path2.Count)
                {
                    DebugMSG("ERRORRRRRRR: path length not equals!!!");
                    return;
                }

                var itworkedhereforpathfinding = true;
                for (int i = 0; i < path.Count; i++)
                {
                    if (path[i].X != path2[i].X || path[i].Y != path2[i].Y)
                    {
                        itworkedhereforpathfinding = false;
                    }
                }
                if (!itworkedhereforpathfinding)
                {
                    DebugMSG("ERRORRRRRRR: path finder not working correctly!!!!");
                }
                else
                {
                    DebugMSG("Paths match :)");
                }

                DebugMSG("Done :)");
            }));
        }