Introduction
Introduction Statistics Contact Development Disclaimer Help
some improvements - chess-puzzles - chess puzzle book generator
git clone git://git.codemadness.org/chess-puzzles
Log
Files
Refs
README
LICENSE
---
commit 78e1ed61ec461637e664b9527f002e232f30ca6e
parent e62dd220612aaada2231586e9c00845700bf4949
Author: Hiltjo Posthuma <[email protected]>
Date: Mon, 22 Jan 2024 20:28:16 +0100
some improvements
- be less strict about parsing UCI moves, just space-separated
- add script to quickly convert PGN to gif, using pgn-extract.
- improve some comments.
- move scripts to root dir.
Diffstat:
M generate.sh | 3 +--
M moves.sh | 12 ++++++------
A pgn_to_gif.sh | 6 ++++++
R docs/stream_lichess.sh -> stream_l… | 0
4 files changed, 13 insertions(+), 8 deletions(-)
---
diff --git a/generate.sh b/generate.sh
@@ -275,8 +275,7 @@ while read -r line; do
echo "$m"
m="${m% }"
- m="${m%[a-h][0-9][a-h][0-9]}"
- m="${m%[qrbnQRBN]}" # possible promotion
+ m="${m%[^ ]*}"
m="${m% }"
test "$prevmoves" = "$m" && break # same, break also
diff --git a/moves.sh b/moves.sh
@@ -1,6 +1,8 @@
#!/bin/sh
# make a list of moves from start to end for each move.
+# output moves to tty with some delay.
+# Show PGN and human speech-like text for the moves.
output_tty() {
while read -r moves; do
clear
@@ -13,7 +15,7 @@ output_tty() {
done
}
-# create animated gifs for puzzle solutions.
+# create an animated gif.
# Dependencies: ffmpeg, ImageMagick, etc.
output_gif() {
tmppal="$(mktemp '/tmp/palette_XXXXXXXX.png')"
@@ -25,20 +27,18 @@ output_gif() {
./fen -o svg "$fen" "$moves" > "$f"
test -s "$f" || break
- # initial puzzle state also
dest="$tmpdir/$n.png"
convert "$f" "$dest"
n=$((n + 1))
done
- # create video / animation.
-
# generate palette for gif.
rm -f "$tmppal"
ffmpeg -loglevel error -stats -i "$tmpdir/%d.png"\
-vf palettegen "$tmppal"
+ # create video / animation.
# wait longer for last frame.
ffmpeg -loglevel error -stats -framerate 1\
-i "$tmpdir/%d.png" \
@@ -64,12 +64,12 @@ while [ "$m" != "" ]; do
echo "$m"
m="${m% }"
- m="${m%[a-h][0-9][a-h][0-9]}"
- m="${m%[qrbnQRBN]}" # possible promotion
+ m="${m%[^ ]*}"
m="${m% }"
test "$prevmoves" = "$m" && break # same, break also
done | \
sort | \
output_gif
+
#output_tty
diff --git a/pgn_to_gif.sh b/pgn_to_gif.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+# Dependencies: pgn-extract for PGN to UCI,
+# see moves.sh for further dependencies.
+
+moves="$(pgn-extract --notags -Wuci)"
+./moves.sh startpos "$moves"
diff --git a/docs/stream_lichess.sh b/stream_lichess.sh
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.