예제 #1
0
        public override object Execute(Reasoner ts, Unifier un, ITerm[] args)
        {
            CheckArguments(args);
            string name   = GetName(args);
            string source = GetSource(args);

            List <string> agArchClasses = GetAgArchClasses(args);

            string          agClass = null;
            ClassParameters bbPars  = null;

            if (args.Length > 2)
            {
                foreach (ITerm t in args[2] as IListTerm)
                {
                    if (t.IsStructure())
                    {
                        Structure s = t as Structure;
                        if (s.GetFunctor().Equals("beliefBaseClass"))
                        {
                            bbPars = new ClassParameters(TestString(s.GetTerm(0)));
                        }
                        else if (s.GetFunctor().Equals("agentClass"))
                        {
                            agClass = TestString(s.GetTerm(0)).ToString();
                        }
                    }
                }
            }
            IRuntimeServices rs = ts.GetUserAgArch().GetRuntimeServices();

            name = rs.CreateAgent(name, source, agClass, agArchClasses, GetSettings(), ts.GetAgent());
            rs.StartAgent(name);

            if (args[0].IsVar())
            {
                return(un.Unifies(new StringTermImpl(name), args[0]));
            }
            else
            {
                return(true);
            }
        }