Skip to content

Instantly share code, notes, and snippets.

@autocorr
Created February 15, 2024 20:23
Show Gist options
  • Save autocorr/386840a2ce25008765230451f0f52bf1 to your computer and use it in GitHub Desktop.
Save autocorr/386840a2ce25008765230451f0f52bf1 to your computer and use it in GitHub Desktop.
Fairy-Stockfish puzzler scripts
#!/usr/bin/env bash
FSF=../fstockfish_bmi_lb
INI=../my_variants.ini
VARIANT=gethenian
NNUE=../nnue/${VARIANT}_l0.5_v1.nnue
BOOK=../books/strong_books/${VARIANT}.epd
COUNT=100000 # number of positions
OUTNAME="$VARIANT"_n"$COUNT".epd
echo ":: Generating games for $VARIANT"
nice -20 python3 generator.py \
--engine $FSF \
--ucioptions Threads=35 \
--ucioptions VariantPath=$INI \
--ucioptions EvalFile=$NNUE \
--ucioptions OwnBook=$BOOK \
--variant $VARIANT \
--count $COUNT \
--max-depth 8 \
--add-move \
> $OUTNAME
#!/usr/bin/env bash
FSF=../fstockfish_bmi_lb
INI=../my_variants.ini
VARIANT=gethenian
NNUE=../nnue/${VARIANT}_l0.5_v1.nnue
INFILE="$VARIANT"_n100000.epd
BASENAME=puzzles_"$VARIANT"
function generate_puzzles_by_depth {
local depth="$2"
local stem=${BASENAME}_d${depth}
local epd=${stem}.epd
echo ":: Generating puzzles for $VARIANT to depth $depth"
nice -20 python3 puzzler.py \
--engine $FSF \
--ucioptions Threads=40 \
--ucioptions VariantPath=$INI \
--ucioptions EvalFile=$NNUE \
--variant $VARIANT \
--depth $depth \
--mate-distance-ratio 3 \
--win-threshold 300 \
$1 \
> /dev/shm/$epd
echo "-- Writing outfile: $epd"
mv /dev/shm/$epd $epd
echo "-- Filtering mates"
nice -20 python3 filter.py -v type=mate $epd > ${stem}_mate.epd
nice -20 python3 filter.py -v type=partial-mate $epd > ${stem}_pmate.epd
nice -20 awk '/type mate/ && !/eval #1;/' $epd > ${stem}_mate_no1.epd
}
D1=8
D2=20
generate_puzzles_by_depth $INFILE $D1
generate_puzzles_by_depth "${BASENAME}_d${D1}_mate_no1.epd" $D2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment