Ejemplo n.º 1
0
        /// <summary>
        ///     Agent learn _knowledgeBits at a learningRate
        ///     OnAfterLearning event is triggered if learning occurs, you can subscribe to this event to treat the new learning
        /// </summary>
        /// <param name="actorKnowledge"></param>
        /// <param name="index"></param>
        /// <param name="learningRate"></param>
        /// <param name="step"></param>
        /// <returns>The real learning value</returns>
        public float AgentKnowledgeLearn(ActorKnowledge actorKnowledge, byte index, float learningRate, ushort step)
        {
            if (actorKnowledge == null)
            {
                throw new ArgumentNullException(nameof(actorKnowledge));
            }

            if (Math.Abs(learningRate) < Tolerance)
            {
                return(0);
            }

            var realLearning = actorKnowledge.KnowledgeBits.UpdateBit(index, learningRate, step);

            CumulativeLearning += realLearning;
            if (!(realLearning > Tolerance))
            {
                return(realLearning);
            }

            var learningEventArgs = new LearningEventArgs(actorKnowledge.Target, index, realLearning);

            OnAfterLearning?.Invoke(this, learningEventArgs);

            return(realLearning);
        }
Ejemplo n.º 2
0
 /// <summary>
 ///     OnAfterLearning event is triggered if learning occurs,
 ///     Subscribe to this event to treat the new learning
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public void AfterLearning(object sender, LearningEventArgs e)
 {
     OnAfterLearning?.Invoke(this, e);
 }