#!/bin/bash # expected command line arguements are $1=[file.pgn] $2=[game_id] $3=[seconds per move] $4=[motor] # for example $ ./thisscript.sh mypgn.pgn 3 2 ./stockfish cores=$5 movenumber=0 COUNTER=0 pgn="$1" sec="$3" gameid="$2" motor="$4" log="log-game-$gameid.txt" ./pgn-extract --notags -Wsan -w2000 --noresults --nomovenumbers -o movesnonumbers.txt "$pgn" ./pgn-extract --notags -Wuci --noresults -o moves.txt "$pgn" rm $log $log".done" for moves in $(cat moves.txt) do let COUNTER=COUNTER+1 #counterminusone=$((COUNTER - 1)) d=`cut -d' ' -f1-$COUNTER moves.txt` move=`cut -d' ' -f$COUNTER movesnonumbers.txt` oddOReven=$(( $COUNTER % 2)) # move counter if [ $oddOReven -eq 0 ]; then dots="" echo $movenumber $dots $move " (ply "$COUNTER ")" else dots="..." let movenumber=movenumber+1 echo $movenumber $dots $move "(ply "$COUNTER ")" fi echo "XXX $movenumber YYY $move YYY $COUNTER YYY $gameid YYY "|cat >>$log (echo "setoption name Threads value $cores";echo 'setoption name Hash value 32';sleep 0.01;echo "position startpos moves $d";sleep 0.01;echo 'go movetime 1110600';"sleep" "$sec"; echo 'quit';)|$motor|grep "cp"| tail -1|sed 's/.*cp\ /YYY /g'|sed 's/ nps.*pv.*//g'|sed 's/ upperbound//g'|sed 's/ lowerbound//g'|cat>>$log;tail -2 $log done cat $log|tr -d '\n'|sed 's/XXX/\n/g'|sed 's/YYY/\t/g'|awk {'print $1,"\t", $2,"\t" $5/-100'}|awk '/./{print $1, "\t" $2, "\t" $3, "\t" $3+x ;};{x=$3}'|sed '1d'|cat >$log".done";echo "analysis written to $log.done"