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
16 # Does not work correctly for attributes containing escaped ]
17 # e.g. "PB[Tony \[Killer\] Nowak]" gets cropped to
20 # Not a big problem, since usually the player name is just
22 sed -n 's/^.*'$1'\[\([^]]*\)\].*$/\1/p' "$sgf"
25 black
="$(sgf_attr PB)"
26 white
="$(sgf_attr PW)"
27 handi
="$(sgf_attr HA)"
29 if [ -n "$handi" ] && [ "$handi" -gt 0 ]; then
31 # Comment following out if you want to include handi games.
32 echo "$sgf: Skipping handicap game" >&2
37 cat "$sgf" | tools
/sgf2gtp.pl | .
/pachi
-d 0 -e patternscan
"$@" |
38 sed -n -e 's/^= //p' |
grep -v '^ *$' |
# skip irrelevant replies
39 while read pattern
; do
40 if [ "$to_play" = black
]; then
47 echo "$pattern" >>"$dbdir/$player"