예제 #1
0
 public static int GetRandomValue(CMethodBase method, Agent pAgent)
 {
     if (method != null)
     {
         ParentType parentType = method.GetParentType();
         Agent      parent     = pAgent;
         if (parentType == ParentType.PT_INSTANCE)
         {
             parent = Agent.GetInstance(method.GetInstanceNameString(), parent.GetContextId());
         }
         return((int)method.run(parent, pAgent));
     }
     return(FrameRandom.Random(RandomMax));
 }
예제 #2
0
        public static bool DoCompare(Agent pAgent, VariableComparator comparator, Property opl, CMethodBase opl_m, Property opr)
        {
            bool bResult = false;

            if (opl != null)
            {
                Agent      agent_left = pAgent;
                ParentType pt         = opl.GetParentType();
                if (pt == ParentType.PT_INSTANCE)
                {
                    agent_left = Agent.GetInstance(opl.GetInstanceNameString(), agent_left.GetContextId());
                    Debug.Check(agent_left != null || Utils.IsStaticClass(opl.GetInstanceNameString()));
                }

                Agent agent_right = pAgent;
                pt = opr.GetParentType();
                if (pt == ParentType.PT_INSTANCE)
                {
                    agent_right = Agent.GetInstance(opr.GetInstanceNameString(), agent_left.GetContextId());
                    Debug.Check(agent_right != null || Utils.IsStaticClass(opr.GetInstanceNameString()));
                }

                bResult = comparator.Execute(agent_left, agent_right);
            }
            else if (opl_m != null)
            {
                ParentType pt         = opl_m.GetParentType();
                Agent      agent_left = pAgent;
                if (pt == ParentType.PT_INSTANCE)
                {
                    agent_left = Agent.GetInstance(opl_m.GetInstanceNameString(), agent_left.GetContextId());
                    Debug.Check(agent_left != null || Utils.IsStaticClass(opl_m.GetInstanceNameString()));
                }

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

                Agent agent_right = pAgent;
                pt = opr.GetParentType();
                if (pt == ParentType.PT_INSTANCE)
                {
                    agent_right = Agent.GetInstance(opr.GetInstanceNameString(), agent_right.GetContextId());
                    Debug.Check(agent_right != null || Utils.IsStaticClass(opr.GetInstanceNameString()));
                }

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

            return(bResult);
        }
            public static int GetRandomValue(CMethodBase method, Agent pAgent)
            {
                int result;

                if (method != null)
                {
                    ParentType parentType = method.GetParentType();
                    Agent      agent      = pAgent;
                    if (parentType == ParentType.PT_INSTANCE)
                    {
                        agent = Agent.GetInstance(method.GetInstanceNameString(), agent.GetContextId());
                    }
                    result = (int)method.run(agent, pAgent);
                }
                else
                {
                    result = (int)FrameRandom.Random(CompositeStochastic.CompositeStochasticTask.RandomMax);
                }
                return(result);
            }
예제 #4
0
        public static bool DoCompare(Agent pAgent, VariableComparator comparator, Property opl, CMethodBase opl_m, Property opr)
        {
            bool result = false;

            if (opl != null)
            {
                Agent      agent      = pAgent;
                ParentType parentType = opl.GetParentType();
                if (parentType == ParentType.PT_INSTANCE)
                {
                    agent = Agent.GetInstance(opl.GetInstanceNameString(), agent.GetContextId());
                }
                Agent agentR = pAgent;
                parentType = opr.GetParentType();
                if (parentType == ParentType.PT_INSTANCE)
                {
                    agentR = Agent.GetInstance(opr.GetInstanceNameString(), agent.GetContextId());
                }
                result = comparator.Execute(agent, agentR);
            }
            else if (opl_m != null)
            {
                ParentType parentType2 = opl_m.GetParentType();
                Agent      agent2      = pAgent;
                if (parentType2 == ParentType.PT_INSTANCE)
                {
                    agent2 = Agent.GetInstance(opl_m.GetInstanceNameString(), agent2.GetContextId());
                }
                object lhs    = opl_m.run(agent2, pAgent);
                Agent  agent3 = pAgent;
                parentType2 = opr.GetParentType();
                if (parentType2 == ParentType.PT_INSTANCE)
                {
                    agent3 = Agent.GetInstance(opr.GetInstanceNameString(), agent3.GetContextId());
                }
                result = comparator.Execute(lhs, agent2, agent3);
            }
            return(result);
        }
예제 #5
0
        public static bool DoCompare(Agent pAgent, VariableComparator comparator, Property opl, CMethodBase opl_m, Property opr)
        {
            bool flag = false;

            if (opl != null)
            {
                Agent agentL = pAgent;
                if (opl.GetParentType() == ParentType.PT_INSTANCE)
                {
                    agentL = Agent.GetInstance(opl.GetInstanceNameString(), agentL.GetContextId());
                }
                Agent instance = pAgent;
                if (opr.GetParentType() == ParentType.PT_INSTANCE)
                {
                    instance = Agent.GetInstance(opr.GetInstanceNameString(), agentL.GetContextId());
                }
                return(comparator.Execute(agentL, instance));
            }
            if (opl_m == null)
            {
                return(flag);
            }
            ParentType parentType = opl_m.GetParentType();
            Agent      parent     = pAgent;

            if (parentType == ParentType.PT_INSTANCE)
            {
                parent = Agent.GetInstance(opl_m.GetInstanceNameString(), parent.GetContextId());
            }
            object lhs    = opl_m.run(parent, pAgent);
            Agent  agentR = pAgent;

            if (opr.GetParentType() == ParentType.PT_INSTANCE)
            {
                agentR = Agent.GetInstance(opr.GetInstanceNameString(), agentR.GetContextId());
            }
            return(comparator.Execute(lhs, parent, agentR));
        }
예제 #6
0
            //generate a random float value between 0 and 1.
            public static float GetRandomValue(CMethodBase method, Agent pAgent)
            {
                float value = 0;

                if (method != null)
                {
                    ParentType pt      = method.GetParentType();
                    Agent      pParent = pAgent;
                    if (pt == ParentType.PT_INSTANCE)
                    {
                        pParent = Agent.GetInstance(method.GetInstanceNameString(), pParent.GetContextId());
                        Debug.Check(pParent != null || Utils.IsStaticClass(method.GetInstanceNameString()));
                    }

                    value = (float)method.run(pParent, pAgent);
                }
                else
                {
                    value = RandomGenerator.GetInstance().GetRandom();
                }

                Debug.Check(value >= 0.0f && value < 1.0f);
                return(value);
            }