Esempio n. 1
0
        protected Problem Complete(Map <PuzzleCell> map, Puzzle puzzle)
        {
            while (true)
            {
                var countIn  = MarkedInside(map).Count;
                var countMin = (int)(0.2 * puzzle.TaskSize * puzzle.TaskSize + 10);

                if (countIn < countMin)
                {
                    AddCells(map, countMin - countIn);
                    continue;
                }

                var verts = VerticesCount(map);
                if (verts < puzzle.MinVertices)
                {
                    AddVertices(map, puzzle.MinVertices);
                    continue;
                }

                break;
            }

            //Print(map);

            var inside = MarkedInside(map);

            var boosters         = new List <Booster>();
            var boosterCellIndex = 1;

            var needBoosters = new List <(BoosterType, int)>
            {
                (BoosterType.Cloning, puzzle.ClonesCount),
                (BoosterType.Drill, puzzle.DrillsCount),
                (BoosterType.Extension, puzzle.ManipulatorsCount),
                (BoosterType.FastWheels, puzzle.FastwheelsCount),
                (BoosterType.MysteriousPoint, puzzle.SpawnsCount),
                (BoosterType.Teleport, puzzle.TeleportsCount)
            };

            foreach (var(type, cnt) in needBoosters)
            {
                for (var i = 0; i < cnt; i++)
                {
                    boosters.Add(new Booster(type, inside[boosterCellIndex++ % inside.Count]));
                }
            }

            var problem = new Problem
            {
                Map       = PuzzleConverter.ConvertMapToPoints(map),
                Boosters  = boosters,
                Obstacles = new List <List <V> >(),
                Point     = inside.First()
            };

            return(problem);
        }
Esempio n. 2
0
        private int VerticesCount(Map <PuzzleCell> map)
        {
            var pts = PuzzleConverter.ConvertMapToPoints(map);

            return(pts.Count);
        }