blob: e091a9c611ffee4dc91d1454fc46de25d2f96c65 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#!/bin/bash
db_file=games_anon.db
query() {
echo "SELECT $1 FROM games WHERE (size == $2) \
and (result != '1-0') and (result != '0-1') and (result != '0-0')\
and (result != '1/2-1/2');"
}
extract() {
cd data
if [ ! -f "$db_file" ]; then
wget "https://www.playtak.com/games_anon.db"
fi
for size in 5 6; do
echo Extracing games of size "$size"...
sqlite3 "$db_file" "$(query $1 $size)" | shuf > "playtak-$size"
done
cd ..
}
process() {
num_games=$1
echo -e "Beginning to process data\n"
for i in 5; do
echo "Size $i..."
./pptdb "$i" "data/playtak-$i" > "data/check-$i"
tail -n21 "data/check-$i"
echo -e "\tStripping overflows and illegal games..."
grep -Fvxf "data/check-$i" "data/playtak-$i" > "data/good-playtak-$i"
echo -e "\tChoosing $num_games from what remains ..."
shuf -n $num_games "data/good-playtak-$i" > "data/smalltak-$i"
echo -en "\tGenerating training data... "
./pptdb "$i" "data/smalltak-$i" generate
echo -e "\tWrote $(wc -l data/training-$i.csv | cut -d\ -f1) samples. Shuffling these..."
tail -n+2 "data/training-$i.csv" | shuf > "data/shuf-$i.csv"
head -n 1 "data/training-$i.csv" | cat "data/shuf-$i.csv" > "data/smalltrain-$i.csv"
rm "data/shuf-$i.csv"
mv "data/smalltrain-5.csv" "data/training-5.csv "
echo -e "\n\tDone! Sample training data in data/training-$i.csv"
done
}
if [ ! -f "data/playtak-5" ]; then
extract notation,result
fi
make pptdb
process 5000
|