package net.javlov;
import javax.swing.JFrame;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
public class TrackingGUI implements EpisodeEndListener {
protected XYSeries reward;
@Override
public void init() {
reward = new XYSeries("Reward", false, false);
XYSeriesCollection xyDataset = new XYSeriesCollection(reward);
JFreeChart chart = ChartFactory.createXYLineChart("Reward", "Episode", "Reward", xyDataset, PlotOrientation.VERTICAL, true, false, false);
ChartPanel chartArea = new ChartPanel(chart, true);
JFrame f = new JFrame("Reward Tracker");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.add(chartArea, "Center");
f.pack();
f.setVisible(true);
}
@Override
public void episodeEnd(EpisodeEndEvent e) {
reward.add(e.getEpisode(), e.getCollectedReward());
}
}