2 # pattern_byplayer - Build a per-player database of used patterns
4 # Invoke this script for each played game, it will add patterns
5 # to the database incrementally; each file in the database contains
6 # patterns played by one player.
8 # You must already have a spatial dictionary generated.
12 # rest of parameters is passed to the patternscan engine
15 # GNU sed mishandles CRLF lines
16 cat "$sgf" |
tr -d '\r' |
sed -n -e 's/'$1'\[\([^]]*\)\]/\1/p'
19 black
="$(sgf_attr PB)"
20 white
="$(sgf_attr PW)"
21 handi
="$(sgf_attr HA)"
23 if [ -n "$handi" ] && [ "$handi" -gt 0 ]; then
25 # Comment following out if you want to include handi games.
26 echo "$sgf: Skipping handicap game" >&2
31 .
/sgf2gtp.pl
"$sgf" | .
/zzgo
-d 0 -e patternscan
"$@" |
32 sed -n -e 's/^= //p' |
grep -v '^ *$' |
# skip irrelevant replies
33 while read pattern
; do
34 if [ "$to_play" = black
]; then
41 echo "$pattern" >>"$dbdir/$player"