Example #1
0
        public bool OverlapInterrupts(AntAIPlanner aPlanner, AntAICondition aConditions)
        {
            int index = -1;

            for (int i = 0, n = _interruptions.Count; i < n; i++)
            {
                index = aPlanner.GetAtomIndex(_interruptions[i]);
                if (aConditions.GetValue(index))
                {
                    return(true);
                }
            }
            return(false);
        }
Example #2
0
        /// <summary>
        /// Описывает состояние.
        /// </summary>
        private void DescribeCondition(AntAICondition aCondition, ref List <string> aResult)
        {
            bool value;

            for (int i = 0; i < AntAIPlanner.MAX_ATOMS; i++)
            {
                if (aCondition.GetMask(i))
                {
                    value = aCondition.GetValue(i);
                    aResult.Add(string.Format("      '<color={2}>{0}</color>' = <color={2}>{1}</color>",
                                              _agent.planner.atoms[i], value, (value) ? _trueColor : _falseColor));
                }
            }
        }
Example #3
0
        /// <summary>
        /// Checking if current world state is equal interruption settings.
        /// </summary>
        /// <param name="aAgent">Ref to the AntAIAgent.</param>
        /// <param name="aWorldState">Current world state.</param>
        /// <returns></returns>
        public bool OverlapInterrupts(AntAIAgent aAgent, AntAICondition aWorldState)
        {
            int index = -1;

            for (int i = 0, n = _interruptions.Count; i < n; i++)
            {
                index = aAgent.planner.GetAtomIndex(_interruptions[i]);
                if (aWorldState.GetValue(index))
                {
                    return(true);
                }
            }
            return(false);
        }
Example #4
0
        public void BindData(string aTitle, AntAIPlanner aPlanner, AntAICondition aCur, AntAICondition aPre)
        {
            title = string.Concat("▶ ", aTitle);

            _items = new List <Item>();
            bool v;

            for (int i = 0, n = AntAIPlanner.MAX_ATOMS; i < n; i++)
            {
                if (aCur.GetMask(i))
                {
                    v = aCur.GetValue(i);
                    _items.Add(new Item
                    {
                        name      = aPlanner.atoms[i],
                        value     = v,
                        isChanged = (v != aPre.GetValue(i))
                    });
                }
            }
        }
Example #5
0
        /// <summary>
        /// Описывает конкретное действие из плана ИИ.
        /// </summary>
        private string DescribePlanAction(AntAICondition aCur, AntAICondition aPre, out int aNumLines)
        {
            var lines = new List <string>();

            lines.Add(string.Format("<b><color={1}>ACTION</color> '<color={2}>{0}</color>'</b>",
                                    aCur.name, _titleColor, _nameColor));
            lines.Add("   <b>Post Conditions</b>");

            bool value;

            for (int j = 0; j < AntAIPlanner.MAX_ATOMS; j++)
            {
                if (aCur.GetMask(j))
                {
                    value = aCur.GetValue(j);
                    if (value != aPre.GetValue(j))
                    {
                        lines.Add(string.Format("      <color=#a873dd><b>></b></color> <i>'<color={2}>{0}</color>' = <color={2}>{1}</color></i>",
                                                _agent.planner.atoms[j], value, (value) ? _trueColor : _falseColor));
                    }
                    else
                    {
                        lines.Add(string.Format("      '<color={2}>{0}</color>' = <color={2}>{1}</color>",
                                                _agent.planner.atoms[j], value, (value) ? _trueColor : _falseColor));
                    }
                }
            }

            StringBuilder text = new StringBuilder();

            for (int i = 0, n = lines.Count; i < n; i++)
            {
                text.AppendLine(lines[i]);
            }

            aNumLines = lines.Count;
            return(text.ToString());
        }