commit 0fe1f6ac19819dd3954b8520db31a66f76d7cf87
parent 6554fcb56e12be089dbbf0e700f6777924e8b5b6
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Thu, 4 Jan 2024 21:03:31 +0100
update TODO and failing tests
This is an edge-case to defend en passant. Fix it later.
2 tests are succeeding, but this is because it is not implemented.
Diffstat:
M | TODO | | | 15 | ++++++++++++++- |
M | tests.sh | | | 30 | ++++++++++++++++++++++++++++++ |
2 files changed, 44 insertions(+), 1 deletion(-)
diff --git a/TODO b/TODO
@@ -1,3 +1,13 @@
+arbitrary test: en-passant defend against mate
+https://lichess.org/editor/rnbqkbnr/pppppppp/8/1P1PP3/2PKQ3/2PQQ3/P1PP1PPP/RNBQ1BNR_w_HAkq_-_0_1?color=white
+
+
+another with pawn removed: cannot defend because then we are in check
+https://lichess.org/editor/rnbqkbnr/pppppppp/8/3PP3/2PKQ3/2PQQ3/P1PP1PPP/RNBQ1BNR_w_HAkq_-_0_1?color=white
+
+
+
+
? canpiecemove(): en passant take (if not in check afterwards).
? ischeckmated(): check en passant take to defend checkmate.
@@ -12,7 +22,10 @@ if so, the piece's file letter, numerical rank, or the exact square is inserted
after the moving piece's name (in that order of preference). Thus, Nge2
specifies that the knight originally on the g-file moves to e2. "
-- add a format" parameter for the CGI mode: vt, pgn, svg, ascii.
+? read PGN to moves?
+
+x add a format" parameter for the CGI mode: vt, pgn, svg, ascii.
+
- improve documentation.
- more tests.
- piece ambiguity.
diff --git a/tests.sh b/tests.sh
@@ -220,6 +220,18 @@ testfen '960, castle king on queenside with many empty squares between them'\
'1rb1krq1/pp2ppb1/3p2p1/1Np4p/2P1P3/1P2N3/P4PPP/1R2KRQB w KQkq - 0 11'\
'e1c1'
+testfen 'black moves pawn en passant into check (not mate, can take en passant)'\
+ 'rnbqkbnr/p2ppppp/1p6/1PpPP3/2PKQ3/2PQQ3/P1PP1PPP/RNBQ1BNR w kq c6 0 2'\
+ 'rnbqkbnr/p1pppppp/1p6/1P1PP3/2PKQ3/2PQQ3/P1PP1PPP/RNBQ1BNR b kq - 0 1'\
+ 'c7c5'
+
+# NOTE: Lichess checks if en passant moves can actually be played, but the PGN
+# reference specifies this doesn't necesarily have to be the case.
+testfen 'black moves pawn en passant into checkmate (cant take en passant to defend)'\
+ 'rnbqkbnr/p3pppp/1p6/2pPP3/2PKQ3/2PQQ3/P1PP1PPP/RNBQ1BNR w kq - 0 2'\
+ 'rnbqkbnr/p1p1pppp/1p6/3PP3/2PKQ3/2PQQ3/P1PP1PPP/RNBQ1BNR b kq - 0 1'\
+ 'c7c5'
+
# TODO: test more chess960 black kingside and queenside castling
# TODO: test more long sequence and halfmove and movenumber counts
}
@@ -288,6 +300,24 @@ testpgn 'Rook on same file, only one is legal, Rd7d1+ -> Rd1+'\
'34. Rc6 Rd1+ 35. Rxd1 Rxd1#'\
'3r2k1/3r2p1/R6p/4bp2/2P1p2P/7N/2P2PP1/2R3K1 w - - 1 34'\
'a6c6 d7d1 c1d1 d8d1'
+
+testpgn 'black moves pawn en passant into check (not mate, can take en passant)'\
+ '1. ... c5+'\
+ 'rnbqkbnr/p1pppppp/1p6/1P1PP3/2PKQ3/2PQQ3/P1PP1PPP/RNBQ1BNR b kq - 0 1'\
+ 'c7c5'
+
+# NOTE: Lichess checks if en passant moves can actually be played, but the PGN
+# reference specifies this doesn't necesarily have to be the case.
+testpgn 'black moves pawn en passant into checkmate (cant take en passant to defend)'\
+ '1. ... c5#'\
+ 'rnbqkbnr/p1p1pppp/1p6/3PP3/2PKQ3/2PQQ3/P1PP1PPP/RNBQ1BNR b kq - 0 1'\
+ 'c7c5'
+
+# check also if the en passant square is set (but it is not legal to play).
+testpgn 'black moves pawn en passant into checkmate (cant take en passant to defend)'\
+ '1. ... c5#'\
+ 'rnbqkbnr/p1p1pppp/1p6/3PP3/2PKQ3/2PQQ3/P1PP1PPP/RNBQ1BNR b kq c6 0 1'\
+ 'c7c5'
}
tests_fen