コード例 #1
0
        void TrackEpisodeProgress(Object sender, EventArgs args)
        {
            // Add all non-void events to current state
            currentEpisode.Events.UnionWith(
                eventTrackers.ConvertAll(l => l.Value())
                .FindAll(e => e != DrivingEvent.NONE));

            // If episode complete, complete and push state object
            if (stopwatch.ElapsedMilliseconds > currentEpisode.EpisodeSize)
            {
                // Create in-game notifications
                UI.Notify("Episode Complete");
                UI.Notify(String.Format("[{0}] Avg Speed: {1}", currentEpisode.EpisodeID, metricTrackers["avg_speed"].Value()));
                UI.Notify(String.Format("[{0}] Avg Road Alignment: {1}", currentEpisode.EpisodeID, metricTrackers["avg_road_alignment"].Value()));
                foreach (var driveEvent in currentEpisode.Events)
                {
                    UI.Notify(String.Format("[{0}] {1}", currentEpisode.EpisodeID, driveEvent.ToString()), true);
                }

                // Update state object, and store
                currentEpisode.AvgSpeed         = metricTrackers["avg_speed"].Value();
                currentEpisode.AvgRoadAlignment = metricTrackers["avg_road_alignment"].Value();

                EpisodeTracker.AddObservation(currentEpisode);
                currentEpisode = new GameEpisode(currentEpisode.EpisodeID + 1);

                // Trigger episode completion event
                stopwatch.Restart();
                EpisodeReset.Invoke(null, null);
            }
        }
コード例 #2
0
 /// <summary>
 /// Calls all associated academies to reset the environment.
 /// </summary>
 public void OnEpisodeReset()
 {
     EpisodeReset?.Invoke(this, EventArgs.Empty);
 }