Exemplo n.º 1
0
        public Solved Solve(State state)
        {
            var solution = new List <ActionBase>();

            if (usePalka)
            {
                BoosterMaster.CreatePalka(state, solution);
            }

            while (state.UnwrappedLeft > 0)
            {
                if (useWheels && state.FastWheelsCount > 0)
                {
                    var useFastWheels = new UseFastWheels();
                    solution.Add(useFastWheels);
                    state.Apply(useFastWheels);
                }
                var part = SolvePart(state);
                solution.AddRange(part);
                state.ApplyRange(part);
            }

            return(new Solved {
                Actions = new List <List <ActionBase> > {
                    solution
                }
            });
        }
Exemplo n.º 2
0
        public Solved Solve(State state)
        {
            var solution = new List <List <ActionBase> > {
                new List <ActionBase>()
            };

            state.BuyBoosters(buy);

            if (usePalka)
            {
                BoosterMaster.CreatePalka(state, solution[0]);
            }
            //BoosterMaster.CloneAttack(state, solution);

            while (state.UnwrappedLeft > 0)
            {
                //Console.Out.WriteLine($"--BEFORE {state.Time}:\n{state.Print()}");

                var partialSolution = new List <List <ActionBase> >();

                while (partialSolution.Count < solution.Count)
                {
                    var part = SolvePart(state, partialSolution);
                    partialSolution.Add(part);
                    //Console.Out.WriteLine($"  PART:\n{part.Format()}");
                }

                for (int i = 0; i < partialSolution[0].Count; i++)
                {
                    var l = new List <(Worker, ActionBase)>();
                    for (int j = 0; j < partialSolution.Count; j++)
                    {
                        solution[j].Add(partialSolution[j][i]);
                        l.Add((state.Workers[j], partialSolution[j][i]));
                    }

                    while (l.Count < state.Workers.Count)
                    {
                        var wait = new Wait();
                        solution.Add(new List <ActionBase> {
                            wait
                        });
                        l.Add((state.Workers[l.Count], wait));
                    }
                    state.Apply(l);
                }

                /*if (state.Time > 1000)
                 *  break;*/
            }

            return(new Solved {
                Actions = solution, Buy = buy.ToList()
            });
        }
        public Solved Solve(State state)
        {
            var solution = new List <ActionBase>();

            if (usePalka)
            {
                BoosterMaster.CreatePalka(state, solution);
            }

            //var tick = 0;

            var used = new HashSet <(V position, int unwrappedLeft)>();

            while (state.UnwrappedLeft > 0)
            {
                if (useWheels && state.FastWheelsCount > 0)
                {
                    var useFastWheels = new UseFastWheels();
                    solution.Add(useFastWheels);
                    state.Apply(useFastWheels);
                }
                if (useDrill && state.DrillCount > 0)
                {
                    var drill = new UseDrill();
                    solution.Add(drill);
                    state.Apply(drill);
                }
                //Console.Out.WriteLine($"--BEFORE:\n{state.Print()}");
                var part = SolvePart(state, used);
                if (part == null)
                {
                    part = SolvePart(state, new HashSet <(V position, int unwrappedLeft)>());
                }
                used.Add((state.SingleWorker.Position, state.UnwrappedLeft));
                solution.AddRange(part);
                state.ApplyRange(part);
                // Console.Out.WriteLine($"  PART:\n{part.Format()}");
                //
                // if (tick++ > 1000)
                //     break;
            }

            return(new Solved {
                Actions = new List <List <ActionBase> > {
                    solution
                }
            });
        }