summaryrefslogtreecommitdiff
path: root/src/genetic/score_histogram.pl
diff options
context:
space:
mode:
Diffstat (limited to 'src/genetic/score_histogram.pl')
-rwxr-xr-xsrc/genetic/score_histogram.pl43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/genetic/score_histogram.pl b/src/genetic/score_histogram.pl
new file mode 100755
index 0000000..facc71a
--- /dev/null
+++ b/src/genetic/score_histogram.pl
@@ -0,0 +1,43 @@
+#!/usr/bin/perl
+
+$gen = $ARGV[0];
+opendir(DIR, ".");
+@files = readdir(DIR);
+closedir(DIR);
+
+$min_score = 999999999; $max_score = 0;
+$total = 0;
+$best = "";
+for $file(@files) {
+ if ($file =~ m/gen(\d+)_\d+\.log/) {
+ $score = 0;
+ next if $1 != $gen;
+ open(FILE, $file) || die $!;
+ $total++;
+ while(<FILE>) {
+ chop;
+ if (m/ correct solutions\s+\:\s+(\d+)/) {
+ $score = $1;
+ last;
+ }
+ }
+ $score = int($score);
+ $scores[$score] += 1;
+ $names{$score} .= "$file ";
+ if ($score > $max_score) {
+ $max_score = $score;
+ $best = $file;
+ }
+ $min_score = $score if ($score < $min_score);
+ close(FILE);
+ }
+}
+
+for ($x = $min_score; $x <= $max_score; $x++) {
+ next if $scores[$x] == 0;
+ printf "%4u : ", $x;
+ print "*" x int($scores[$x] / $total * 60);
+ print " ($scores[$x], $names{$x})\n";
+}
+print "Best was $best\n";
+system "tail -22 $best";