Example #1
0
        /// <summary>
        /// Implement the Q Learning update rule using experience replay
        /// </summary>
        private void UpdateKnowledge()
        {
            var mini_batch   = GenerateMiniBatch();
            var trainingData = new List <Tuple <State, double[]> >();
            var actions      = Enum.GetValues(typeof(ActionType)).Cast <ActionType>();

            foreach (var experience in mini_batch)
            {
                var targetValues    = new Dictionary <ActionType, double>();
                var estimatedValues = Q[experience.From];

                foreach (var action in actions)
                {
                    targetValues[action] = QUpdate(experience, action, estimatedValues[action]);
                }

                trainingData.Add(new Tuple <State, double[]>(experience.From, targetValues.Values.ToArray()));
            }

            Q.Train(trainingData);
            OnTrainingComplete?.Invoke(this, new OnTrainingCompleteArgs());
        }
Example #2
0
 public async Task __DoneTraining__()
 {
     OnTrainingComplete?.Invoke();
 }
Example #3
0
 public void __DoneTraining__()
 {
     OnTrainingComplete?.Invoke();
 }