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