Exemplo n.º 1
0
        public static bool EvaluteCompute(Agent pAgent, Property opl, Property opr1, CMethodBase opr1_m, EComputeOperator opr, Property opr2, CMethodBase opr2_m)
        {
            bool   bValid = false;
            object value1 = null;

            if (opl != null)
            {
                if (opr1_m != null)
                {
                    bValid = true;
                    value1 = opr1_m.Invoke(pAgent);
                }
                else if (opr1 != null)
                {
                    bValid = true;
                    Agent pParentR = opr1.GetParentAgent(pAgent);

                    value1 = opr1.GetValue(pParentR);
                }

                Debug.Check(value1 != null, "weird, have you modified your meta? please reexport your trees");

                if (opr2_m != null)
                {
                    bValid = true;
                    object value2 = opr2_m.Invoke(pAgent);

                    Agent  pParentOpl  = opl.GetParentAgent(pAgent);
                    object returnValue = Details.ComputeValue(value1, value2, opr);

                    opl.SetValue(pParentOpl, returnValue);
                }
                else if (opr2 != null)
                {
                    bValid = true;
                    Agent pParentL = opl.GetParentAgent(pAgent);
                    Agent pParentR = opr2.GetParentAgent(pAgent);

                    object value2 = opr2.GetValue(pParentR);

                    object returnValue = Details.ComputeValue(value1, value2, opr);

                    opl.SetValue(pParentL, returnValue);
                }
            }

            return(bValid);
        }
            //generate a random float value between 0 and 1.
            public static float GetRandomValue(CMethodBase method, Agent pAgent)
            {
                float value = 0;

                if (method != null)
                {
                    value = (float)method.Invoke(pAgent);
                }
                else
                {
                    value = RandomGenerator.GetInstance().GetRandom();
                }

                Debug.Check(value >= 0.0f && value < 1.0f);
                return(value);
            }
Exemplo n.º 3
0
        public static bool EvaluteCompute(Agent pAgent, Property opl, Property opr1, CMethodBase opr1_m, EComputeOperator opr, Property opr2, CMethodBase opr2_m)
        {
            bool   bValid = false;
            object value1 = null;

            if (opl != null)
            {
                if (opr1_m != null)
                {
                    bValid = true;
                    value1 = opr1_m.Invoke(pAgent);
                }
                else if (opr1 != null)
                {
                    bValid = true;
                    Agent pParentR = opr1.GetParentAgent(pAgent);

                    value1 = opr1.GetValue(pParentR);
                }

                if (opr2_m != null)
                {
                    bValid = true;
                    object value2 = opr2_m.Invoke(pAgent);

                    Agent  pParentOpl  = opl.GetParentAgent(pAgent);
                    object returnValue = Details.ComputeValue(value1, value2, opr);

                    opl.SetValue(pParentOpl, returnValue);
                }
                else if (opr2 != null)
                {
                    bValid = true;
                    Agent pParentL = opl.GetParentAgent(pAgent);
                    Agent pParentR = opr2.GetParentAgent(pAgent);

                    object value2 = opr2.GetValue(pParentR);

                    object returnValue = Details.ComputeValue(value1, value2, opr);

                    opl.SetValue(pParentL, returnValue);
                }
            }

            return(bValid);
        }
Exemplo n.º 4
0
        public static bool DoCompare(Agent pAgent, VariableComparator comparator, Property opl, CMethodBase opl_m, Property opr, CMethodBase opr_m)
        {
            bool bResult = false;

            if (opl != null)
            {
                Agent agent_left  = opl.GetParentAgent(pAgent);
                Agent agent_right = opr != null?opr.GetParentAgent(pAgent) : opr_m.GetParentAgent(pAgent);

                bResult = comparator.Execute(agent_left, agent_right);
            }
            else if (opl_m != null)
            {
                Agent agent_left = opl_m.GetParentAgent(pAgent);

                object returnValue = opl_m.Invoke(agent_left, pAgent);

                Agent agent_right = opr != null?opr.GetParentAgent(pAgent) : opr_m.GetParentAgent(pAgent);

                bResult = comparator.Execute(returnValue, agent_left, agent_right);
            }

            return(bResult);
        }