Beispiel #1
0
 /// <summary>
 /// Builds the specified step.
 /// </summary>
 /// <param name="step">The step.</param>
 public void Build(Step step)
 {
     RunWorkerAsync(step);
 }
Beispiel #2
0
        private Step ProcessMove(Step current, Movement m)
        {
            int num;
            var after = (Field)current.Field.Clone();

            after.DoMove(m);


            var step = new Step
            {
                Id       = GetId(),
                Field    = after,
                Move     = m,
                Number   = current.Number + 1,
                Progress = after.GetProgress(),
                Previous = current
            };

            if (step.Progress == 0)
            {
                step.Stop(StopReason.Solution);
                return(step);
            }

            int existsStepNumber;

            if (GetLevelForProgress(step.Progress, out num))
            {
                if (step.Number - num > DiffLimit)
                {
                    step.Stop(StopReason.ProgressFoundEarly);
                    return(step);
                }
            }
            if (GetLevelForProgress(0, out num))
            {
                if (step.Number >= DiffLimit)
                {
                    step.Stop(StopReason.SolutionFoundEarly);
                    return(step);
                }
            }

            if (GetLevelForField(after, out existsStepNumber))
            {
                // поле найдено на том же или меньшем ходу
                if (step.Number >= existsStepNumber)
                {
                    step.Stop(StopReason.FieldFoundEarly);

                    //var salt = Randomizer.GetInteger();
                    //TypeSerializer<Step>.ToXmlFile(salt + ".xml", existsStep);
                    //TypeSerializer<Step>.ToXmlFile(salt + "_.xml", step);
                    return(step);
                }
            }



            return(step);
        }