Skip to content

Commit

Permalink
Added test dir
Browse files Browse the repository at this point in the history
Also: score PGN changed so autoflush is '1'
Added timeout = 0 to settings.
  • Loading branch information
Nicholas Harding committed Apr 6, 2014
1 parent 3a0a820 commit b07127b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
13 changes: 8 additions & 5 deletions scorePGN/scorePGN.pl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

my %cfg = %{LoadFile("/opt/settings.yaml")};

# Set autoflush for debugging.
$| = 1;

GetOptions(
\%cfg,
'userid:s',
Expand Down Expand Up @@ -88,7 +91,7 @@
my @opt_coordinate_moves;
my @opt_move_scores;
my @opt_move_mate_in;

my $pos = Chess::Rep->new;
my $current_fen;
my $halfmovecounter = 0;
Expand All @@ -98,11 +101,11 @@
# set current state as FEN
$current_fen = $pos->get_fen;
++$halfmovecounter;

# update board with current move & capture move info
my $status = $pos->go_move($move);
my $move_as_coordinates = $status->{from}.$status->{to};

push @coordinate_moves, $move_as_coordinates;

# code to skip 3 lines if too early in game
Expand All @@ -115,10 +118,10 @@
push @opt_move_mate_in, 'NA';
next;
}

my $playedmove = choosemove(fen => $current_fen, searchmoves => [$move_as_coordinates], depth => $cfg{Depth}, verbose => $cfg{verbose});
my $bestmove = choosemove(fen => $current_fen, depth => $cfg{Depth}, verbose => $cfg{verbose});

# dummy pos
my $dummy_position = Chess::Rep->new($current_fen);
my $hypothet_move = $dummy_position->go_move($bestmove->{move});
Expand Down
1 change: 1 addition & 0 deletions scorePGN/settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ sleeptime: 600
EvalAfter: 4
hashsize: 1024
dbpath: /data/chessAnalysis.db
timeout: 0
driver: SQLite
18 changes: 18 additions & 0 deletions t/TEST.pgn
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[Event "Coimbatore"]
[Site "Coimbatore"]
[Date "1987.??.??"]
[Round "?"]
[White "Sahu, Sekhar Chandra"]
[Black "Anand, Viswanathan"]
[Result "0-1"]
[WhiteElo "2380"]
[BlackElo "2505"]
[ECO "B84"]

1.e4 c5 2.Nf3 e6 3.d4 cxd4 4.Nxd4 a6 5.Be2 Nf6 6.Nc3 Qc7 7.O-O Be7 8.Be3 O-O
9.f4 d6 10.Qe1 Nbd7 11.Kh1 b5 12.a3 Bb7 13.Bf3 Rac8 14.Rd1 Nb6 15.Bc1 Nfd7
16.f5 e5 17.f6 Nxf6 18.Nf5 Ne8 19.Rd3 Rd8 20.Qf2 Bf6 21.b3 Kh8 22.Be3 Nc8
23.Rfd1 Bc6 24.Kg1 Qb8 25.Bc5 g6 26.Ng3 Qc7 27.Be3 Bg7 28.Nd5 Bxd5 29.Rxd5 f5
30.exf5 gxf5 31.Bg5 Ne7 32.Nh5 e4 33.Nxg7 Nxg7 34.Bxe7 Qxe7 35.Be2 Rf6 36.c4 bxc4
37.Bxc4 f4 38.Qd4 f3 39.Re5 Qf8 40.Rxe4 d5 41.Bxd5 fxg2 42.Re5 Rf4 43.Qa1 Qc5+
44.Kxg2 Qc2+ 45.Kg1 Rg4+ 46.Kh1 Rh4 47.h3 Rxh3+ 48.Kg1 Qh2+ 49.Kf1 Rf8+ 50.Ke1 Re3+ 0-1

0 comments on commit b07127b

Please sign in to comment.