Here is a version that will output the average of ten runs (rounded to the nearest integer):
package wild; import animals.*; import javax.swing.JFrame; import javax.swing.JLabel; public class Wild { private static final Class[] classes = { Bear.class, Lion.class, Stone.class, Wolf.class }; public static final int MAP_SIZE = Math.round((float) Math.sqrt(classes.length + 3) * 20); public static void main(String[] args) { int size = MAP_SIZE; double[] avgs = new double[classes.length]; for (int i = 0; i < avgs.length; i++) { avgs[i] = 0; } for (int n = 0; n < 10; n++) { // change 10 to the number of runs you'd like to make. Game game = new Game(size); Statistics stats = new Statistics(game, classes); for (Class c : classes) { game.populate(c, 100); } stats.update(); for (int i = 0; i < 1000; i++) { game.iterate(); stats.update(); } int[] livings = stats.nums(); if (n != 0) { for (int i = 0; i < livings.length; i++) { avgs[i] = (avgs[i] * n + livings[i]) / (n + 1); } } else { for (int i = 0; i < livings.length; i++) { avgs[i] = livings[i]; } } } String s = "<html>"; for (int i = 0; i < classes.length; i++) { s += classes[i] + " - " + Math.round(avgs[i]) + "<br>"; } s += "</html>"; JFrame frame = new JFrame(); frame.add(new JLabel(s)); frame.pack(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLocationRelativeTo(null); frame.setVisible(true); } }