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 = (
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 {