summaryrefslogtreecommitdiff
path: root/share/hackvr/examples/chess/gnuchess-to-hackvr.sh
diff options
context:
space:
mode:
authorepoch <epoch@hacking.allowed.org>2019-02-06 00:53:08 -0600
committerepoch <epoch@hacking.allowed.org>2019-02-06 00:53:08 -0600
commitbf16b7b8593d4013adbd03838af5a2fb3bce34ee (patch)
tree25944f4d4907a075e513f03b7e37a99f4c813752 /share/hackvr/examples/chess/gnuchess-to-hackvr.sh
parent73c246a797fc6c1bac132b4eb242e1c90540e2d4 (diff)
downloadhackvr-bf16b7b8593d4013adbd03838af5a2fb3bce34ee.tar.gz
hackvr-bf16b7b8593d4013adbd03838af5a2fb3bce34ee.zip
I forgot to add the examples dir somehow. they're back. tictactoe works again too.
Diffstat (limited to 'share/hackvr/examples/chess/gnuchess-to-hackvr.sh')
-rwxr-xr-xshare/hackvr/examples/chess/gnuchess-to-hackvr.sh31
1 files changed, 31 insertions, 0 deletions
diff --git a/share/hackvr/examples/chess/gnuchess-to-hackvr.sh b/share/hackvr/examples/chess/gnuchess-to-hackvr.sh
new file mode 100755
index 0000000..0b94a87
--- /dev/null
+++ b/share/hackvr/examples/chess/gnuchess-to-hackvr.sh
@@ -0,0 +1,31 @@
+#!/bin/sh
+tee /dev/stderr | while read first second third;do
+ if [ "_$first" = "_feature" ];then
+ printf "# just gnuchess saying what features it has: %s %s %s\n" "$first" "$second" "$third" >&2
+ elif printf "%s\n" "$first" | grep '^[0-9][0-9]*\.$' >/dev/null 2>&1;then
+ #we made a successful move.
+ ### how to tell hackvr to move the piece now? $second should contain what the move was.
+ printf "# Hey! Hackvr! do this move: %s\n" "$second" >&2
+ if [ "_$second" = "_..." ];then #computer/other person made a move.
+ move=$third
+ else
+ move=$second
+ fi
+ from=$(printf "%s\n" "$move" | fold -w1 | head -n2 | tr -d '\n')
+ to=$(printf "%s\n" "$move" | fold -w1 | tail -n+3 | head -n2 | tr -d '\n')
+ x=$(echo "a b c d e f g h" | tr ' ' '\n' | grep -n "$(printf "%s\n" "$to" | fold -w1 | head -n1)" | cut -d: -f1)
+ y=$(printf "%s\n" "$to" | fold -w1 | tail -n1)
+ magic=$(printf "%s\n" "$move" | fold -w1 | tail -n+5 | tr -d '\n')
+### if the board is on the wall we need to use x and y
+# printf "piece_%s move %s %s 0\n" "$from" "$x" "$y" | tee /dev/stderr
+### the board is on the floor atm. use x and z
+ printf "piece_%s move %s 0 %s\n" "$from" "$x" "$y" | tee /dev/stderr
+
+ printf "#delete the old piece_%s group\n"
+ printf "epoch deletegroup piece_%s\n" "$to"
+ printf "epoch renamegroup piece_%s piece_%s\n" "$from" "$to" | tee /dev/stderr
+ else
+ #something else.
+ printf "oops. something else happened. let's see: %s %s %s\n" "$first" "$second" "$third" >&2
+ fi
+done