Introduction
Introduction Statistics Contact Development Disclaimer Help
test all possible castling positions - chess-puzzles - chess puzzle book genera…
git clone git://git.codemadness.org/chess-puzzles
Log
Files
Refs
README
LICENSE
---
commit 4edab675e79782ae15324c3a890c87068521b999
parent 551d1075b050556fafd5ff8c86e0b3a92bbbda46
Author: Hiltjo Posthuma <[email protected]>
Date: Sat, 27 Jan 2024 21:02:21 +0100
test all possible castling positions
Castling is perfect now, except for illegal UCI moves.
Diffstat:
M TODO | 5 -----
M tests.sh | 290 +++++++++++++++++------------…
2 files changed, 158 insertions(+), 137 deletions(-)
---
diff --git a/TODO b/TODO
@@ -1,8 +1,3 @@
-- current castle tests are wrong,
- UCI move: for castling is kingpos, rookpos.
- test all possible chess960 and classical positions.
- - castling code can be simplified and end position for castling is the same
- as classical.
- rename fen.c to be more unique so it can be installed in $PATH.
- more tests.
- test more long sequence and halfmove and movenumber counts.
diff --git a/tests.sh b/tests.sh
@@ -181,6 +181,7 @@ testfen 'check halfmove counter on check, white checks blac…
'rnbqkbnr/ppp1pp1p/6p1/3p4/3P4/4P3/PPP2PPP/RNBQKBNR w KQkq - 20 1'\
'f1b5'
+# TODO: this is incorrect (illegal move), fix it?
# 960 white queenside castle
testfen '960 white queenside castle'\
'qrn1bk1n/ppb1pprp/2p3p1/3p4/1B1P4/3NPB2/PPP2PPP/Q1KR2RN b q - 5 6'\
@@ -605,28 +606,26 @@ testpgn 'castles chess 960'\
tests_fen
tests_pgn
-if test "$statuscode" = "1"; then
- echo "$failed tests failed"
-else
- echo "All tests OK"
-fi
-
-exit "$statuscode"
-
# Test all castle positions for both sides for chess960
# this includes classical positions.
-# TODO: also test PGN, should match O-O or O-O-O
-(IFS=" "
+IFS=" "
while read -r kingside f kingpos r1pos r2pos; do
+ # test last part of the side that is tested.
+ # 5RK1 - kingside
+ # 2KR4 - queenside
+
+ # lowercase for black
+ fb="$(printf '%s' "$f" | tr '[:upper:]' '[:lower:]')"
+
# test white kingside or queenside castle.
if test "$kingside" = "1"; then
- fullfen="$f w Kk - 0 1"
- expect="6kr/pppppppp/8/8/8/8/PPPPPPPP/5RK1 b k - 1 1"
+ fullfen="${fb}/pppppppp/8/8/8/8/PPPPPPPP/${f} w Kk - 0 1"
+ expect="${fb}/pppppppp/8/8/8/8/PPPPPPPP/5RK1 b k - 1 1"
move="${kingpos}1${r2pos}1"
else
- fullfen="$f w Qq - 0 1"
- expect="1r1k4/pppppppp/8/8/8/8/PPPPPPPP/2KR4 b q - 1 1"
+ fullfen="${fb}/pppppppp/8/8/8/8/PPPPPPPP/${f} w Qq - 0 1"
+ expect="${fb}/pppppppp/8/8/8/8/PPPPPPPP/2KR4 b q - 1 1"
move="${kingpos}1${r1pos}1"
fi
testfen "Chess960 position, $fullfen (white), $move" \
@@ -634,132 +633,159 @@ while read -r kingside f kingpos r1pos r2pos; do
"$fullfen" \
"$move"
+ if test "$kingside" = "1"; then
+ expect="1. O-O"
+ else
+ expect="1. O-O-O"
+ fi
+ testpgn "Chess960 position, $fullfen (white), $move" \
+ "$expect" \
+ "$fullfen" \
+ "$move"
+
# test black kingside or queenside castle.
if test "$kingside" = "1"; then
- fullfen="$f b Kk - 0 1"
- expect="5rk1/pppppppp/8/8/8/8/PPPPPPPP/6KR w K - 1 2"
+ fullfen="${fb}/pppppppp/8/8/8/8/PPPPPPPP/${f} b Kk - 0 1"
+ expect="5rk1/pppppppp/8/8/8/8/PPPPPPPP/${f} w K - 1 2"
move="${kingpos}8${r2pos}8"
else
- fullfen="$f b Qq - 0 1"
- expect="2kr4/pppppppp/8/8/8/8/PPPPPPPP/1R1K4 w Q - 1 2"
+ fullfen="${fb}/pppppppp/8/8/8/8/PPPPPPPP/${f} b Qq - 0 1"
+ expect="2kr4/pppppppp/8/8/8/8/PPPPPPPP/${f} w Q - 1 2"
move="${kingpos}8${r1pos}8"
fi
-
testfen "Chess960 position, $fullfen (black), $move" \
"$expect" \
"$fullfen" \
"$move"
-done) <<!
-0 1r1k4/pppppppp/8/8/8/8/PPPPPPPP/1R1K4 d b e
-0 1r1k4/pppppppp/8/8/8/8/PPPPPPPP/1R1K4 d b f
-0 1r1k4/pppppppp/8/8/8/8/PPPPPPPP/1R1K4 d b g
-0 1r1k4/pppppppp/8/8/8/8/PPPPPPPP/1R1K4 d b h
-0 1r2k3/pppppppp/8/8/8/8/PPPPPPPP/1R2K3 e b f
-0 1r2k3/pppppppp/8/8/8/8/PPPPPPPP/1R2K3 e b g
-0 1r2k3/pppppppp/8/8/8/8/PPPPPPPP/1R2K3 e b h
-0 1r3k2/pppppppp/8/8/8/8/PPPPPPPP/1R3K2 f b g
-0 1r3k2/pppppppp/8/8/8/8/PPPPPPPP/1R3K2 f b h
-0 1r4k1/pppppppp/8/8/8/8/PPPPPPPP/1R4K1 g b h
-0 1rk5/pppppppp/8/8/8/8/PPPPPPPP/1RK5 c b d
-0 1rk5/pppppppp/8/8/8/8/PPPPPPPP/1RK5 c b e
-0 1rk5/pppppppp/8/8/8/8/PPPPPPPP/1RK5 c b f
-0 1rk5/pppppppp/8/8/8/8/PPPPPPPP/1RK5 c b g
-0 1rk5/pppppppp/8/8/8/8/PPPPPPPP/1RK5 c b h
-0 2r1k3/pppppppp/8/8/8/8/PPPPPPPP/2R1K3 e c f
-0 2r1k3/pppppppp/8/8/8/8/PPPPPPPP/2R1K3 e c g
-0 2r1k3/pppppppp/8/8/8/8/PPPPPPPP/2R1K3 e c h
-0 2r2k2/pppppppp/8/8/8/8/PPPPPPPP/2R2K2 f c g
-0 2r2k2/pppppppp/8/8/8/8/PPPPPPPP/2R2K2 f c h
-0 2r3k1/pppppppp/8/8/8/8/PPPPPPPP/2R3K1 g c h
-0 2rk4/pppppppp/8/8/8/8/PPPPPPPP/2RK4 d c e
-0 2rk4/pppppppp/8/8/8/8/PPPPPPPP/2RK4 d c f
-0 2rk4/pppppppp/8/8/8/8/PPPPPPPP/2RK4 d c g
-0 2rk4/pppppppp/8/8/8/8/PPPPPPPP/2RK4 d c h
-0 3r1k2/pppppppp/8/8/8/8/PPPPPPPP/3R1K2 f d g
-0 3r1k2/pppppppp/8/8/8/8/PPPPPPPP/3R1K2 f d h
-0 3r2k1/pppppppp/8/8/8/8/PPPPPPPP/3R2K1 g d h
-0 3rk3/pppppppp/8/8/8/8/PPPPPPPP/3RK3 e d f
-0 3rk3/pppppppp/8/8/8/8/PPPPPPPP/3RK3 e d g
-0 3rk3/pppppppp/8/8/8/8/PPPPPPPP/3RK3 e d h
-0 4r1k1/pppppppp/8/8/8/8/PPPPPPPP/4R1K1 g e h
-0 4rk2/pppppppp/8/8/8/8/PPPPPPPP/4RK2 f e g
-0 4rk2/pppppppp/8/8/8/8/PPPPPPPP/4RK2 f e h
-0 5rk1/pppppppp/8/8/8/8/PPPPPPPP/5RK1 g f h
-0 r1k5/pppppppp/8/8/8/8/PPPPPPPP/R1K5 c a d
-0 r1k5/pppppppp/8/8/8/8/PPPPPPPP/R1K5 c a e
-0 r1k5/pppppppp/8/8/8/8/PPPPPPPP/R1K5 c a f
-0 r1k5/pppppppp/8/8/8/8/PPPPPPPP/R1K5 c a g
-0 r1k5/pppppppp/8/8/8/8/PPPPPPPP/R1K5 c a h
-0 r2k4/pppppppp/8/8/8/8/PPPPPPPP/R2K4 d a e
-0 r2k4/pppppppp/8/8/8/8/PPPPPPPP/R2K4 d a f
-0 r2k4/pppppppp/8/8/8/8/PPPPPPPP/R2K4 d a g
-0 r2k4/pppppppp/8/8/8/8/PPPPPPPP/R2K4 d a h
-0 r3k3/pppppppp/8/8/8/8/PPPPPPPP/R3K3 e a f
-0 r3k3/pppppppp/8/8/8/8/PPPPPPPP/R3K3 e a g
-0 r3k3/pppppppp/8/8/8/8/PPPPPPPP/R3K3 e a h
-0 r4k2/pppppppp/8/8/8/8/PPPPPPPP/R4K2 f a g
-0 r4k2/pppppppp/8/8/8/8/PPPPPPPP/R4K2 f a h
-0 r5k1/pppppppp/8/8/8/8/PPPPPPPP/R5K1 g a h
-0 rk6/pppppppp/8/8/8/8/PPPPPPPP/RK6 b a c
-0 rk6/pppppppp/8/8/8/8/PPPPPPPP/RK6 b a d
-0 rk6/pppppppp/8/8/8/8/PPPPPPPP/RK6 b a e
-0 rk6/pppppppp/8/8/8/8/PPPPPPPP/RK6 b a f
-0 rk6/pppppppp/8/8/8/8/PPPPPPPP/RK6 b a g
-0 rk6/pppppppp/8/8/8/8/PPPPPPPP/RK6 b a h
-1 1k1r4/pppppppp/8/8/8/8/PPPPPPPP/1K1R4 b a d
-1 1k2r3/pppppppp/8/8/8/8/PPPPPPPP/1K2R3 b a e
-1 1k3r2/pppppppp/8/8/8/8/PPPPPPPP/1K3R2 b a f
-1 1k4r1/pppppppp/8/8/8/8/PPPPPPPP/1K4R1 b a g
-1 1k5r/pppppppp/8/8/8/8/PPPPPPPP/1K5R b a h
-1 1kr5/pppppppp/8/8/8/8/PPPPPPPP/1KR5 b a c
-1 2k1r3/pppppppp/8/8/8/8/PPPPPPPP/2K1R3 c a e
-1 2k1r3/pppppppp/8/8/8/8/PPPPPPPP/2K1R3 c b e
-1 2k2r2/pppppppp/8/8/8/8/PPPPPPPP/2K2R2 c a f
-1 2k2r2/pppppppp/8/8/8/8/PPPPPPPP/2K2R2 c b f
-1 2k3r1/pppppppp/8/8/8/8/PPPPPPPP/2K3R1 c a g
-1 2k3r1/pppppppp/8/8/8/8/PPPPPPPP/2K3R1 c b g
-1 2k4r/pppppppp/8/8/8/8/PPPPPPPP/2K4R c a h
-1 2k4r/pppppppp/8/8/8/8/PPPPPPPP/2K4R c b h
-1 2kr4/pppppppp/8/8/8/8/PPPPPPPP/2KR4 c a d
-1 2kr4/pppppppp/8/8/8/8/PPPPPPPP/2KR4 c b d
-1 3k1r2/pppppppp/8/8/8/8/PPPPPPPP/3K1R2 d a f
-1 3k1r2/pppppppp/8/8/8/8/PPPPPPPP/3K1R2 d b f
-1 3k1r2/pppppppp/8/8/8/8/PPPPPPPP/3K1R2 d c f
-1 3k2r1/pppppppp/8/8/8/8/PPPPPPPP/3K2R1 d a g
-1 3k2r1/pppppppp/8/8/8/8/PPPPPPPP/3K2R1 d b g
-1 3k2r1/pppppppp/8/8/8/8/PPPPPPPP/3K2R1 d c g
-1 3k3r/pppppppp/8/8/8/8/PPPPPPPP/3K3R d a h
-1 3k3r/pppppppp/8/8/8/8/PPPPPPPP/3K3R d b h
-1 3k3r/pppppppp/8/8/8/8/PPPPPPPP/3K3R d c h
-1 3kr3/pppppppp/8/8/8/8/PPPPPPPP/3KR3 d a e
-1 3kr3/pppppppp/8/8/8/8/PPPPPPPP/3KR3 d b e
-1 3kr3/pppppppp/8/8/8/8/PPPPPPPP/3KR3 d c e
-1 4k1r1/pppppppp/8/8/8/8/PPPPPPPP/4K1R1 e a g
-1 4k1r1/pppppppp/8/8/8/8/PPPPPPPP/4K1R1 e b g
-1 4k1r1/pppppppp/8/8/8/8/PPPPPPPP/4K1R1 e c g
-1 4k1r1/pppppppp/8/8/8/8/PPPPPPPP/4K1R1 e d g
-1 4k2r/pppppppp/8/8/8/8/PPPPPPPP/4K2R e a h
-1 4k2r/pppppppp/8/8/8/8/PPPPPPPP/4K2R e b h
-1 4k2r/pppppppp/8/8/8/8/PPPPPPPP/4K2R e c h
-1 4k2r/pppppppp/8/8/8/8/PPPPPPPP/4K2R e d h
-1 4kr2/pppppppp/8/8/8/8/PPPPPPPP/4KR2 e a f
-1 4kr2/pppppppp/8/8/8/8/PPPPPPPP/4KR2 e b f
-1 4kr2/pppppppp/8/8/8/8/PPPPPPPP/4KR2 e c f
-1 4kr2/pppppppp/8/8/8/8/PPPPPPPP/4KR2 e d f
-1 5k1r/pppppppp/8/8/8/8/PPPPPPPP/5K1R f a h
-1 5k1r/pppppppp/8/8/8/8/PPPPPPPP/5K1R f b h
-1 5k1r/pppppppp/8/8/8/8/PPPPPPPP/5K1R f c h
-1 5k1r/pppppppp/8/8/8/8/PPPPPPPP/5K1R f d h
-1 5k1r/pppppppp/8/8/8/8/PPPPPPPP/5K1R f e h
-1 5kr1/pppppppp/8/8/8/8/PPPPPPPP/5KR1 f a g
-1 5kr1/pppppppp/8/8/8/8/PPPPPPPP/5KR1 f b g
-1 5kr1/pppppppp/8/8/8/8/PPPPPPPP/5KR1 f c g
-1 5kr1/pppppppp/8/8/8/8/PPPPPPPP/5KR1 f d g
-1 5kr1/pppppppp/8/8/8/8/PPPPPPPP/5KR1 f e g
-1 6kr/pppppppp/8/8/8/8/PPPPPPPP/6KR g a h
-1 6kr/pppppppp/8/8/8/8/PPPPPPPP/6KR g b h
-1 6kr/pppppppp/8/8/8/8/PPPPPPPP/6KR g c h
-1 6kr/pppppppp/8/8/8/8/PPPPPPPP/6KR g d h
-1 6kr/pppppppp/8/8/8/8/PPPPPPPP/6KR g e h
-1 6kr/pppppppp/8/8/8/8/PPPPPPPP/6KR g f h
+
+ if test "$kingside" = "1"; then
+ expect="1. ... O-O"
+ else
+ expect="1. ... O-O-O"
+ fi
+ testpgn "Chess960 position, $fullfen (black), $move" \
+ "$expect" \
+ "$fullfen" \
+ "$move"
+done <<!
+0 1R1K4 d b e
+0 1R1K4 d b f
+0 1R1K4 d b g
+0 1R1K4 d b h
+0 1R2K3 e b f
+0 1R2K3 e b g
+0 1R2K3 e b h
+0 1R3K2 f b g
+0 1R3K2 f b h
+0 1R4K1 g b h
+0 1RK5 c b d
+0 1RK5 c b e
+0 1RK5 c b f
+0 1RK5 c b g
+0 1RK5 c b h
+0 2R1K3 e c f
+0 2R1K3 e c g
+0 2R1K3 e c h
+0 2R2K2 f c g
+0 2R2K2 f c h
+0 2R3K1 g c h
+0 2RK4 d c e
+0 2RK4 d c f
+0 2RK4 d c g
+0 2RK4 d c h
+0 3R1K2 f d g
+0 3R1K2 f d h
+0 3R2K1 g d h
+0 3RK3 e d f
+0 3RK3 e d g
+0 3RK3 e d h
+0 4R1K1 g e h
+0 4RK2 f e g
+0 4RK2 f e h
+0 5RK1 g f h
+0 R1K5 c a d
+0 R1K5 c a e
+0 R1K5 c a f
+0 R1K5 c a g
+0 R1K5 c a h
+0 R2K4 d a e
+0 R2K4 d a f
+0 R2K4 d a g
+0 R2K4 d a h
+0 R3K3 e a f
+0 R3K3 e a g
+0 R3K3 e a h
+0 R4K2 f a g
+0 R4K2 f a h
+0 R5K1 g a h
+0 RK6 b a c
+0 RK6 b a d
+0 RK6 b a e
+0 RK6 b a f
+0 RK6 b a g
+0 RK6 b a h
+1 1K1R4 b a d
+1 1K2R3 b a e
+1 1K3R2 b a f
+1 1K4R1 b a g
+1 1K5R b a h
+1 1KR5 b a c
+1 2K1R3 c a e
+1 2K1R3 c b e
+1 2K2R2 c a f
+1 2K2R2 c b f
+1 2K3R1 c a g
+1 2K3R1 c b g
+1 2K4R c a h
+1 2K4R c b h
+1 2KR4 c a d
+1 2KR4 c b d
+1 3K1R2 d a f
+1 3K1R2 d b f
+1 3K1R2 d c f
+1 3K2R1 d a g
+1 3K2R1 d b g
+1 3K2R1 d c g
+1 3K3R d a h
+1 3K3R d b h
+1 3K3R d c h
+1 3KR3 d a e
+1 3KR3 d b e
+1 3KR3 d c e
+1 4K1R1 e a g
+1 4K1R1 e b g
+1 4K1R1 e c g
+1 4K1R1 e d g
+1 4K2R e a h
+1 4K2R e b h
+1 4K2R e c h
+1 4K2R e d h
+1 4KR2 e a f
+1 4KR2 e b f
+1 4KR2 e c f
+1 4KR2 e d f
+1 5K1R f a h
+1 5K1R f b h
+1 5K1R f c h
+1 5K1R f d h
+1 5K1R f e h
+1 5KR1 f a g
+1 5KR1 f b g
+1 5KR1 f c g
+1 5KR1 f d g
+1 5KR1 f e g
+1 6KR g a h
+1 6KR g b h
+1 6KR g c h
+1 6KR g d h
+1 6KR g e h
+1 6KR g f h
!
+
+if test "$statuscode" = "1"; then
+ echo "$failed tests failed"
+else
+ echo "All tests OK"
+fi
+
+exit "$statuscode"
You are viewing proxied material from codemadness.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.