Beispiel #1
0
        /// <summary>
        /// Evaluate the specified action.
        /// </summary>
        /// <param name="action">Action.</param>
        public Appraisal Evaluate(AIAction action)
        {
            if (action == null)
            {
                throw new ArgumentNullException("Action argument cannot be null.");
            }

            List <ICondition> conditions = TacticalMind.Input.FighterConditions;

            if (conditions == null)
            {
                throw new ArgumentNullException("ICondition variable cannot be null.");
            }

            if (conditions.Count < 1)
            {
                throw new ArgumentNullException("ICondition variable cannot be of length 0.");
            }

            // TODO: conditions should be stored per character and there should
            // probably be a more elegant way to access them.
            ICondition physicalCondition = conditions [3];

            TechniqueProficiency proficiency = ((FightingTechniqueAction)action).Proficiency;

            if (proficiency == null)
            {
                throw new ArgumentNullException("FightingTechniqueAction variable cannot be null.");
            }

            float     endurance = ((PhysicalCondition)physicalCondition).Condition;
            Appraisal appraisal = new Appraisal();

            // If the current endurance is above the pre-defined
            // threshold then the basic score will be equal to the
            // initial score. Otherwise the score will be reduced or
            // increased by the result of dividing the endurance by
            // the maximum endurance, depending on whether it's a punch
            // or a kick.
            if (endurance >= _modificationThreshold * TacticalMind.MAX_PHYSICAL_CONDITION_VALUE)
            {
                appraisal.BasicScore = _initialScore;
            }
            else if (proficiency.TechniqueBodyPart.PartType == BodyPartType.LeftArm ||
                     proficiency.TechniqueBodyPart.PartType == BodyPartType.RightArm)
            {
                appraisal.BasicScore = _initialScore - endurance / TacticalMind.MAX_PHYSICAL_CONDITION_VALUE;
            }
            else if (proficiency.TechniqueBodyPart.PartType == BodyPartType.LeftLeg ||
                     proficiency.TechniqueBodyPart.PartType == BodyPartType.RightLeg)
            {
                appraisal.BasicScore = _initialScore + endurance / TacticalMind.MAX_PHYSICAL_CONDITION_VALUE;
            }
            else
            {
                appraisal.BasicScore = _initialScore;
            }

            return(appraisal);
        }
Beispiel #2
0
        /// <summary>
        /// Constructs the action.
        /// </summary>
        /// <returns>The action.</returns>
        /// <param name="techniqueProdiciency">Technique prodiciency.</param>
        ///
        /// TODO: currently this class is tightly coupled with class TechniqueProficiency.
        /// They should be loosely coupled instead.
        public override AIAction ConstructAction(TechniqueProficiency techniqueProdiciency)
        {
            if (techniqueProdiciency == null)
            {
                throw new System.ArgumentException("techniqueProdiciency reference not found.");
            }

            return(new FightingTechniqueAction(techniqueProdiciency));
        }
Beispiel #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FightingTechniqueAction"/> class.
        /// </summary>
        /// <param name="techniqueProdiciency">Technique prodiciency.</param>
        ///
        /// TODO: currently this class is tightly coupled with class TechniqueProficiency.
        /// They should be loosely coupled instead.
        public FightingTechniqueAction(TechniqueProficiency techniqueProdiciency)
        {
            if (techniqueProdiciency == null)
            {
                throw new System.ArgumentException("techniqueProdiciency reference not found.");
            }

            _techniqueProdiciency = techniqueProdiciency;
        }
Beispiel #4
0
        /// <summary>
        /// Evaluate the specified action in terms of the technique proficiency corresponding
        /// to it. In other words, measure the worth (to the character) of the action depending
        /// on how skilled he is at the fighting technique tied to the action.
        /// </summary>
        /// <remarks>>
        /// This assumes the given action is of type FightingTechniqueAction.
        /// </remarks>
        /// <param name="action">The Action to evaluate.</param>
        /// <returns>
        /// An Appraisal instance containing the utility measure of the given action.
        /// </returns>
        public Appraisal Evaluate(AIAction action)
        {
            if (action == null)
            {
                throw new ArgumentNullException("Action argument cannot be null.");
            }

            TechniqueProficiency proficiency = ((FightingTechniqueAction)action).Proficiency;

            // The appraisal's basic score is linearly dependent on the proficiency
            // of the character in the technique corresponding to the given action.
            Appraisal appraisal = new Appraisal(proficiency.Proficiency);

            return(appraisal);
        }
        /// <summary>
        /// Evaluate the specified action.
        /// </summary>
        /// <param name="action">Action.</param>
        public Appraisal Evaluate(AIAction action)
        {
            if (action == null)
            {
                throw new ArgumentNullException("Action argument cannot be null.");
            }

            TechniqueProficiency proficiency = ((FightingTechniqueAction)action).Proficiency;

            if (proficiency == null)
            {
                throw new ArgumentNullException("FightingTechniqueAction variable cannot be null.");
            }

            BodyPart bodyPart = proficiency.TechniqueBodyPart;

            if (bodyPart == null)
            {
                throw new ArgumentNullException("BodyPart variable cannot be null.");
            }

            float damage = bodyPart.DamagePercentage;

            Appraisal appraisal = new Appraisal();

            if (damage <= 5)
            {
                appraisal.BasicScore = _initialScore;
            }
            else if (damage <= 35)
            {
                appraisal.BasicScore = _initialScore - damage / 100;
            }
            else if (damage <= 85)
            {
                appraisal.BasicScore = (_initialScore - damage / 100) / TacticalMind.BODY_PART_DAMAGE_COEFFICIENT;
            }
            else
            {
                appraisal.BasicScore = 0.0f;
            }

            return(appraisal);
        }
Beispiel #6
0
        } // End PickActions

        #endregion

        #region Private methods

        /// <summary>
        /// Creates a fighting action and adds it to the list of actions
        /// for the character to perform.
        /// </summary>
        /// <param name="action">The Action to create a FightingAction from.</param>
        private static void createFightingAction(AIAction action)
        {
            TechniqueProficiency proficiency = ((FightingTechniqueAction)action).Proficiency;

            FightingAction fightingAction = ScriptableObject.CreateInstance <FightingAction>();

            // TODO: the Utility-Based system should probably not have
            // direct access to StrategicFightingArtsMechanism.
            //fightingAction.ActionFighter = StrategicFightingArtsMechanism.ActiveFighter;
            fightingAction.ActionFighter    = _fightManager.ActiveFighter;
            fightingAction.AttackerBodyPart = proficiency.TechniqueBodyPart;
            // TODO: need to have a mechanism for selecting the body part to be
            // targeted by the selected action.
            //fightingAction.TargetBodyPart = BodyPartSearchSupport.FindBodyPartByPartType(proficiency.Technique.TargetBodyParts[0].PartType,
            //    StrategicFightingArtsMechanism.InactiveFighter.Character.BodyParts);
            fightingAction.TargetBodyPart = BodyPartSearchSupport.FindBodyPartByPartType(proficiency.Technique.TargetBodyParts[0].PartType,
                                                                                         _fightManager.InactiveFighter.Character.BodyParts);
            fightingAction.Technique = proficiency.Technique;

            // Add the fighting action to the queue of actions
            // for the active fighter.
            //StrategicFightingArtsMechanism.AddFightingAction(fightingAction);
            _fightManager.AddFightingAction(fightingAction);
        }
 /// <summary>
 /// Constructs the action.
 /// </summary>
 /// <returns>The action.</returns>
 /// <param name="techniqueProdiciency">Technique prodiciency.</param>
 ///
 /// TODO: currently this class is tightly coupled with class TechniqueProficiency.
 /// They should be loosely coupled instead.
 public abstract AIAction ConstructAction(TechniqueProficiency techniqueProdiciency);