gridBagConstraints.weightx = .5;
gridBagConstraints.gridwidth = 4;
gridBagConstraints.gridy = gridy + 1;
gridBagConstraints.insets = new Insets(1, 1, 1, 1);
leftbottom.add(statusbar, gridBagConstraints);
Timer t = new Timer(200, new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
if (timeStarted == 0)
status1.setText(messages.getString("status.ready"));
else
{
long ms = new Date().getTime() - timeStarted;
long seconds = ms / 1000;
long minutes = seconds / 60;
long hours = minutes / 60;
status1.setText(messages.getString("status.running", hours % 60, minutes % 60, seconds % 60));
}
if (lastUpdate != 0)
{
long ms = new Date().getTime() - lastUpdate;
long seconds = ms / 1000;
long minutes = seconds / 60;
long hours = minutes / 60;
status2.setText(messages.getString("status.lastUpdate", hours % 60, minutes % 60, seconds % 60));
{
double evaluations = ec.getGamesPlayed();
double evalseconds = (System.currentTimeMillis() - timeStarted);
evalseconds = evalseconds / 1000.0;
double permsPerSecond = evaluations;
permsPerSecond /= evalseconds;
StringBuilder stats = new StringBuilder();
int threadIndex = 0;
stats.append(messages.getString("stats.gamesPlayed", evaluations / 1000));
stats.append("\n").append(messages.getString("stats.maxBuildOrderLength", ec.getChromosomeLength()));
stats.append("\n").append(messages.getString("stats.stagnationLimit", ec.getStagnationLimit()));
stats.append("\n").append(messages.getString("stats.gamesPlayedPerSec", (int) permsPerSecond));
stats.append("\n").append(messages.getString("stats.mutationRate", ec.getBaseMutationRate() / ec.getChromosomeLength()));
for (Double d : ec.getBestScores())
stats.append("\n").append(messages.getString("stats.processor", threadIndex, ec.getEvolutionsSinceDiscovery(threadIndex++), d));
statsText.setText(stats.toString());
}
}
statusbar.repaint();
}
});
t.start();
}