示例#1
0
        public static GraphContainer Generate(GenerateParameters parameters)
        {
            parameters.Seed = parameters.Seed > -1 ? parameters.Seed : new Random((int)DateTime.Now.Ticks).Next();

            _maxDepth      = parameters.MaxDepth;
            _maxBranches   = parameters.MaxBranches;
            _maxIterations = parameters.MaxIterations;
            _skipOdds      = parameters.SkipOdds;

            _rng = new Random(parameters.Seed);

            PuzzleGoal.ResetIdCounter();

            var last = new PuzzleGoal("Last Puzzle", "", new List <PuzzleGoal>()
            {
                new PuzzleGoal("End Game")
            });

            var allPuzzles = GenerateGoals(nextPuzzle: last);

            var first = new PuzzleGoal("First puzzle", "", allPuzzles[allPuzzles.Count]);
            var start = new PuzzleStart(first);

            var container = Create();
            var graph     = container.CreateGraph(start);

            graph.Rename();
            graph.Position();

            if (parameters.DoSort)
            {
                graph.Sort(maxIterations: _maxIterations);
            }
            if (parameters.DoSwap)
            {
                graph.Swap(maxIterations: _maxIterations);
            }
            if (parameters.DoSort)
            {
                graph.Sort(direction: -1, maxIterations: _maxIterations);
            }

            if (parameters.DoCompressY)
            {
                graph.CompressY();
            }

            if (parameters.DoCompressX)
            {
                graph.CompressX();
            }
            if (parameters.DoCompressX)
            {
                graph.CompressX(direction: -1);
            }

            graph.Plot();

            return(container);
        }
示例#2
0
        public static string GenerateXML(GenerateParameters parameters)
        {
            _puzzleCount = 0;

            var graph = Generate(parameters);

            return(Serialize(graph));
        }