]> git.sesse.net Git - remoteglot/commitdiff
Output historic analysis (not used by the frontend yet).
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 19 Nov 2014 22:24:55 +0000 (23:24 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 19 Nov 2014 22:24:55 +0000 (23:24 +0100)
config.pm
remoteglot.pl

index 94f4ea1775d4bbfbb27d93be0df3f68b1d4d2f79..182d6ebeb31af6a5233cf47e32b1a92fbdeacf6b 100644 (file)
--- a/config.pm
+++ b/config.pm
@@ -8,6 +8,7 @@ our $server = "freechess.org";
 our $nick = "SesseBOT";
 our $target = "GMCarlsen";  # FICS username or HTTP to a PGN file.
 our $json_output = "/srv/analysis.sesse.net/www/analysis.json";
+our $json_history_dir = "/srv/analysis.sesse.net/www/history/";  # undef for none.
 
 our $engine_cmdline = "./stockfish";
 our %engine_config = (
index fb74e6eab5c0d04c454b532ae047ed509fe2141c..9b1635c3ebc8955642fb68bff08abf46921dd3a1 100755 (executable)
@@ -744,6 +744,16 @@ sub output_json {
 
        my $encoded = JSON::XS::encode_json($json);
        atomic_set_contents($remoteglotconf::json_output, $encoded);
+
+       if (exists($pos_calculating->{'history'}) &&
+           defined($remoteglotconf::json_history_dir)) {
+               my $halfmove_num = scalar @{$pos_calculating->{'history'}};
+               (my $fen = $pos_calculating->fen()) =~ tr,/ ,-_,;
+               my $filename = $remoteglotconf::json_history_dir . "/move$halfmove_num-$fen.json";
+
+               # TODO: Avoid overwriting earlier analysis if it's better.
+               atomic_set_contents($filename, $encoded);
+       }
 }
 
 sub atomic_set_contents {