/// <summary>
        /// Request to evaluate the codelet with given time
        /// </summary>
        public bool EvaluateCodelet(Codelet codelet, bool debugMode)
        {
            if (codelet.GetFutureCodelet(nameActive) != null)
            {
                return(false);
            }
            currentEvaluating = codelet;

            codelet.AddFutureCodelet(nameActive, isEvaluating);
            if (debugMode)
            {
                //Profiler.Start(codelet.GetType().FullName);
                //SingleUserLog.Update(codelet.ToString(), Profiler.NumExecuted(codelet.ToString()));
                //SingleUserLog.Replace(codelet.ToString());
            }
            receiver.Receive("EvaluateCodelet", codelet);
            bool done = codelet.Evaluate();

            if (debugMode)
            {
                //Profiler.End(used * 1000);
            }

            codelet.RemoveFutureCodelet(nameActive);

            if (done && codelet.Salience > 0)
            {
                // Complete it!
                CompleteCodelet(codelet);
            }
            currentEvaluating = null;

            return(done);
        }
        /// <summary>
        /// Delete a codelet at random
        /// </summary>
        public virtual void DeleteRandomCodelet()
        {
            Codelet codelet = SelectRandomCodelet();

            if (codelet.GetFutureCodelet(nameActive) == null)
            {
                DeleteCodelet(codelet);
            }
        }
        /// <summary>
        /// Request to complete a codelet
        /// </summary>
        public virtual bool CompleteCodelet(Codelet codelet)
        {
            if (codelet.GetFutureCodelet(nameActive) != null)
            {
                return(true);
            }

            codelet.AddFutureCodelet(nameActive, isCompleting);
            if (codelet.Complete())
            {
                DeleteCodelet(codelet);
                return(true);
            }
            else
            {
                codelet.RemoveFutureCodelet(nameActive);
                return(false);
            }
        }
Example #4
0
        /// <summary> 
        /// Request to evaluate the codelet with given time
        /// </summary> 
        public bool EvaluateCodelet(Codelet codelet, bool debugMode)
        {
            if (codelet.GetFutureCodelet(nameActive) != null)
                return false;
            currentEvaluating = codelet;

            codelet.AddFutureCodelet(nameActive, isEvaluating);
            if (debugMode) {
                //Profiler.Start(codelet.GetType().FullName);
                //SingleUserLog.Update(codelet.ToString(), Profiler.NumExecuted(codelet.ToString()));
                //SingleUserLog.Replace(codelet.ToString());
            }
            receiver.Receive("EvaluateCodelet", codelet);
            bool done = codelet.Evaluate();
            if (debugMode) {
                //Profiler.End(used * 1000);
            }

            codelet.RemoveFutureCodelet(nameActive);

            if (done && codelet.Salience > 0) {
                // Complete it!
                CompleteCodelet(codelet);
            }
            currentEvaluating = null;

            return done;
        }
Example #5
0
        /// <summary> 
        /// Request to complete a codelet
        /// </summary> 
        public virtual bool CompleteCodelet(Codelet codelet)
        {
            if (codelet.GetFutureCodelet(nameActive) != null)
                return true;

            codelet.AddFutureCodelet(nameActive, isCompleting);
            if (codelet.Complete()) {
                DeleteCodelet(codelet);
                return true;
            } else {
                codelet.RemoveFutureCodelet(nameActive);
                return false;
            }
        }