Ejemplo n.º 1
0
        public MoveEvaluationResult EvaluateScore(IScoreEvaluationContext context)
        {
            MoveEvaluationResult result = new MoveEvaluationResult();

            var nextEntity = context.FieldMap[context.NextRow][context.NextColumn];

            if (nextEntity.IsMoveAllowedOnThis)
            {
                if (myCustomEvaluator != null)
                {
                    var moveEvaluatorContext = GetMoveEvaluatorContext(context);

                    var moveResult = myCustomEvaluator.EvaluateMove(moveEvaluatorContext);

                    if (moveResult.IsMovePossible)
                    {
                        result.EvaluatedScore = moveResult.EvaluatedScore + myMoveScore;
                    }
                    else
                    {
                        result.EvaluatedScore = context.CurrentScore;
                    }
                    result.IsMovePossible = moveResult.IsMovePossible;
                    result.IsGameWon      = moveResult.IsGameWon;
                    result.UpdatdEntities = moveResult.UpdatdEntities;
                }
                else
                {
                    result.IsMovePossible = true;
                    result.EvaluatedScore = context.CurrentScore + nextEntity.ScoringWeight + myMoveScore;
                    if (nextEntity.DisplayText == "Ex")
                    {
                        result.IsGameWon = true;
                    }
                }
            }
            else
            {
                result.IsMovePossible = false;
                result.EvaluatedScore = context.CurrentScore;
            }

            if (result.UpdatdEntities.Any())
            {
                foreach ((int Row, int Column, IMapEntity UpdatedEntity)resultUpdatdEntity in result.UpdatdEntities)
                {
                    context.FieldMap[resultUpdatdEntity.Row][resultUpdatdEntity.Column] = new DataBoundMapEntity(resultUpdatdEntity.UpdatedEntity);
                }
            }

            return(result);
        }
Ejemplo n.º 2
0
        public MoveEvaluationResult EvaluateScore(IScoreEvaluationContext context)
        {
            MoveEvaluationResult result = new MoveEvaluationResult();
            var nextEntity = context.FieldMap[context.NextRow, context.NextColumn];

            if (nextEntity.IsMoveAllowedOnThis)
            {
                result.IsMovePossible = true;

                result.EvaluatedScore = context.CurrentScore + nextEntity.ScoringWeight + myMoveScore;
            }
            else
            {
                result.IsMovePossible = false;
                result.EvaluatedScore = context.CurrentScore;
            }

            return(result);
        }