public static ChartPanel getKillsPerEachDeathByBotType(BotStatistic stats) { XYSeriesCollection ds = new XYSeriesCollection(); LinkedList<BotSeries> series = new LinkedList<BotSeries>(); for (String botName : stats.getAllBotFamilies()) { series.add(new BotSeries(new XYSeries(botName), 0, 0, botName)); } for (BotSeries s : series) { s.series.add(0, 0); s.d1 = StatsTools.countBotsOfGivenFamilly(s.botName, stats); } for (Kill k : stats.kills) { for (BotSeries s : series) { if (k.killer.startsWith(s.botName) || k.victim.startsWith(s.botName)) { if (k.killer.startsWith(s.botName)) { s.int1++; } if (k.victim.startsWith(s.botName)) { s.int2++; } float val = 0; if (s.int2 != 0) { val = (float) s.int1 / (float) s.int2; } s.series.add(k.time / 10, val / s.d1); } } } for (BotSeries s : series) { ds.addSeries(s.series); } JFreeChart c = ChartFactory.createXYLineChart( "Kills per each death by bot type in time", "time [s]", "kills / deaths", ds, PlotOrientation.VERTICAL, true, true, true); ChartPanel cp = new ChartPanel(c); return cp; }
public static ChartPanel getAvgRewardsChart(BotStatistic stats) { XYSeriesCollection ds = new XYSeriesCollection(); LinkedList<BotSeries> series = new LinkedList<BotSeries>(); for (String botName : stats.getAllRewardedBotNames()) { series.add(new BotSeries(new XYSeries(botName), 0, 0, botName)); } String allName = "all RL"; int botsNum = stats.getAllRewardedBotNames().size(); series.add(new BotSeries(new XYSeries(allName), 0, 0, allName)); int segmentSize = stats.rewards.size() / avgRewardsChartSegments; if (segmentSize < 1) { segmentSize = 1; } int i = 0; for (Reward k : stats.rewards) { for (BotSeries s : series) { if (k.botName.equals(s.botName)) { s.d1 += k.reward; } } i++; if (i % segmentSize == 0) { BotSeries as = series.getLast(); for (BotSeries s : series) { if (s.botName.equals(as.botName)) continue; s.series.add(k.time - segmentSize / 2 / 10, s.d1 / segmentSize); as.d1 += s.d1; s.d1 = 0; } as.series.add(k.time - segmentSize / 2 / 10, as.d1 / (botsNum * segmentSize)); as.d1 = 0; } } for (BotSeries s : series) { ds.addSeries(s.series); } JFreeChart c = ChartFactory.createXYLineChart( "avg reward gaining speed", "time [s]", "avg reward gaining speed", ds, PlotOrientation.VERTICAL, true, true, true); ChartPanel cp = new ChartPanel(c); return cp; }
public static ChartPanel getDeathsInTimeByBotType(BotStatistic stats) { XYSeriesCollection ds = new XYSeriesCollection(); LinkedList<BotSeries> series = new LinkedList<BotSeries>(); for (String botName : stats.getAllBotFamilies()) { series.add(new BotSeries(new XYSeries(botName), 0, 0, botName)); } for (BotSeries s : series) { s.series.add(0, 0); s.int2 = StatsTools.countBotsOfGivenFamilly(s.botName, stats); } for (Kill k : stats.kills) { for (BotSeries s : series) { if (k.victim.startsWith(s.botName)) { s.int1++; s.series.add(k.time / 10, (double) s.int1 / s.int2); } } } for (BotSeries s : series) { ds.addSeries(s.series); } JFreeChart c = ChartFactory.createXYLineChart( "Deaths by bot type in time", "time [s]", "deaths", ds, PlotOrientation.VERTICAL, true, true, true); ChartPanel cp = new ChartPanel(c); return cp; }
public static ChartPanel getRewardsInTimeByEachBot(BotStatistic stats) { XYSeriesCollection ds = new XYSeriesCollection(); LinkedList<BotSeries> series = new LinkedList<BotSeries>(); synchronized (stats) { for (String botName : stats.getAllRewardedBotNames()) { series.add(new BotSeries(new XYSeries(botName), 0, 0, botName)); } for (BotSeries s : series) { s.series.add(0, 0); } String allName = "all avg"; int botsNum = stats.getAllRewardedBotNames().size(); series.add(new BotSeries(new XYSeries(allName), 0, 0, allName)); int segmentSize = stats.rewards.size() / rewardsChartSegments; if (segmentSize < 1) { segmentSize = 1; } int i = 0; for (BotStatistic.Reward k : stats.rewards) { for (BotSeries s : series) { if (k.reward != 0 && s.botName.equals(k.botName)) { s.d1 += k.reward; s.int1 = k.time; break; } } BotSeries as = series.getLast(); as.d1 += k.reward / botsNum; i++; if (i % segmentSize == 0) { for (BotSeries s : series) { s.series.add(s.int1 / 10, s.d1); } } } } for (BotSeries s : series) { ds.addSeries(s.series); } JFreeChart c = ChartFactory.createXYLineChart( "Rewards by each bot in time", "time [s]", "rewards", ds, PlotOrientation.VERTICAL, true, true, true); // XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) // ((XYPlot)c.getPlot()).getRenderer(); // r.setDrawOutlines(true); // r.setShapesVisible(true); ChartPanel cp = new ChartPanel(c); return cp; }