aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2023-01-14 15:54:23 +0100
committerLoic Guegan <manzerbredes@mailbox.org>2023-01-14 15:54:23 +0100
commitb7667d1d40045ecd840b9b192c2740e5f83e7eba (patch)
tree4f3b365150c64538429e1d02fa80e635316602ca /tools
parent79cf6b2634eaa3cf3ff67d875847b6934a48a911 (diff)
Add the lichess chess-openings database
Diffstat (limited to 'tools')
-rwxr-xr-xtools/openings.sh33
1 files changed, 33 insertions, 0 deletions
diff --git a/tools/openings.sh b/tools/openings.sh
new file mode 100755
index 0000000..b0f1e04
--- /dev/null
+++ b/tools/openings.sh
@@ -0,0 +1,33 @@
+#!/bin/bash
+# OChess is using the lichess chess-openings database
+# that can be found here: https://github.com/lichess-org/chess-openings
+
+# Init variables
+urldb="https://github.com/lichess-org/chess-openings"
+tmp=$(mktemp -d)
+wai=$(dirname $(readlink -f "$0")) # Current script directory
+dst="${wai}/../src/binres/"
+
+# Fetch database
+git clone "$urldb" "$tmp"
+
+# Generate c_str from database
+cd $tmp
+wxbin2c a.tsv a_tsv.hpp
+wxbin2c b.tsv b_tsv.hpp
+wxbin2c c.tsv c_tsv.hpp
+wxbin2c d.tsv d_tsv.hpp
+wxbin2c e.tsv e_tsv.hpp
+
+# Combine c_str files
+cat a_tsv.hpp > openings.hpp
+cat b_tsv.hpp >> openings.hpp
+cat c_tsv.hpp >> openings.hpp
+cat d_tsv.hpp >> openings.hpp
+cat e_tsv.hpp >> openings.hpp
+
+# Save
+mv openings.hpp "$dst"
+
+# Cleaning
+rm -rf "$tmp"