Exemple #1
0
        public void RunUntilNewArea(PositionGuide <PositionData> guide, int positionCase = 0)
        {
            HasMoved        = false;
            PositionCounter = positionCase;
            int stepsDone = 0;

            while (true)
            {
                //var fallbackDone = false;
                int areaId = guide.PositionAreaId(Position.Data);

                var options = new List <GWAction <PositionData, ActionData> >();
                foreach (var actionFinder in ActionHandling.ActionFinders)
                {
                    // filter actions that have been researched
                    var newOptions = actionFinder.FindActions(Position);
                    options.AddRange(newOptions);
                    //options.AddRange(newOptions.Where(a => !Position.Data.ActionsTried.Contains(a.Data.FingerPrint)));
                }


                if (HasMoved)
                {
                    options = (options.Where(op => op.HasImpactOnTarget)).ToList();
                }
                //TODO: filter double actions (from several actionFinders)
                if (options.NullOrEmpty())
                {   //no more options that help reach a target, can stop searching
                    break;
                }

                if (options.NullOrEmpty())
                {   //no more options that help reach a target, can stop searching
                    break;
                }

                //choose by multievaluation:
                ChosenAction = MultiEvaluation.Do(options, ActionHandling.ActionEvaluators, Weights, 1, MultiEvaluationOptions).First();


                PreSolution.Position = ActionHandling.ActionExecuter.CreateNewPosition(ChosenAction);
                HasMoved             = true;
                stepsDone++;

                //check if new area is reached
                int newAreaId = guide.PositionAreaId(Position.Data);
                if (areaId != newAreaId)
                {
                    MovedToNewArea         = true;
                    Position.IsEndPosition = guide.IsEndPosition(Position.Data);
                    OnTargetReached(this);
                    break;
                }
            }
            //PreSolution.InternalCanBeFiltered = MovedToNewArea;
            //Score = Position.Data.NextCheckPoint.Score(Position.Data);
        }
Exemple #2
0
        public void RunDoOneThing(PositionGuide <PositionData> guide, int positionCase = 0)
        {
            HasMoved        = false;
            PositionCounter = positionCase;
            int stepsDone = 0;

            while (stepsDone == 0)
            {
                //int areaId = guide.PositionAreaId(Position.Data);

                var options = new List <GWAction <PositionData, ActionData> >();
                foreach (var actionFinder in ActionHandling.ActionFinders)
                {
                    // filter actions that have been researched
                    var newOptions = actionFinder.FindActions(Position);
                    options.AddRange(newOptions);
                    //options.AddRange(newOptions.Where(a => !Position.Data.ActionsTried.Contains(a.Data.FingerPrint)));
                }

                if (options.NullOrEmpty())
                {   //no more options that help reach a target, can stop searching
                    break;
                }

                // choose by multievaluation:
                if (options.Count > 1)
                {
                    ChosenAction = MultiEvaluation.Do(options, ActionHandling.ActionEvaluators, Weights, 1, MultiEvaluationOptions).First();
                }
                else
                {
                    ChosenAction = options.First();
                }

                // execute action
                PreSolution.Position = ActionHandling.ActionExecuter.CreateNewPosition(ChosenAction);
                HasMoved             = true;
                stepsDone++;

                //check if new area is reached
                //int newAreaId = guide.PositionAreaId(Position.Data);
                //if (areaId != newAreaId)
                {
                    Position.IsEndPosition = guide.IsEndPosition(Position.Data);
                    OnTargetReached(this);
                    break;
                }
            }
        }