summaryrefslogtreecommitdiff
path: root/tictactoe/run
diff options
context:
space:
mode:
authorepoch <epoch@hacking.allowed.org>2017-04-18 01:33:44 -0500
committerepoch <epoch@hacking.allowed.org>2017-04-18 01:33:44 -0500
commita204330db26a0c3f5b4e88bdc495af350e262ab4 (patch)
treed92a57aca247f796c590eb5606ca64be4b8ed3af /tictactoe/run
parent34628f9a0df01adc1d17e44f569600dc7d9d1414 (diff)
downloadhackvr-a204330db26a0c3f5b4e88bdc495af350e262ab4.tar.gz
hackvr-a204330db26a0c3f5b4e88bdc495af350e262ab4.zip
the changes needed to get tictactoe running pretty.
Diffstat (limited to 'tictactoe/run')
-rwxr-xr-xtictactoe/run22
1 files changed, 22 insertions, 0 deletions
diff --git a/tictactoe/run b/tictactoe/run
new file mode 100755
index 0000000..4e06a75
--- /dev/null
+++ b/tictactoe/run
@@ -0,0 +1,22 @@
+#!/bin/bash
+turn=$( expr $RANDOM % 2)
+echo "go. player: $turn"
+stdbuf -oL cat <(echo "$USER" move 0 -5 0) board p | ../src/hackvr_x11 "$USER" 2>/dev/null \
+ | stdbuf -oL uniq \
+ | grep --line-buffered clicked \
+ | stdbuf -oL cut '-d ' -f5 | while read group;do
+ if grep "_" <<<$group >/dev/null;then
+# xmessage "CUT IT OUT"
+ echo CUT IT OUT > /dev/stderr
+ else
+ turn=$(expr \( $turn + 1 \) % 2)
+ printf "# turn: %d\n" "$turn" > /dev/stderr
+ printf "$USER deletegroup %s\n" "$group"
+#need to get the first point of the group clicked and translate the new shape by that much
+ translatex="$(grep "$group" board | grep -v '^#' | tr -s ' ' | cut '-d ' -f5)"
+ translatey="$(grep "$group" board | grep -v '^#' | tr -s ' ' | cut '-d ' -f6)"
+ cat "marker$turn"
+ printf "%s move 0 %s %s\n" "_marker" "$(expr "$translatex")" "$(expr -1 \* "$translatey" + 2)"
+ printf "%s renamegroup _marker _marker%s%s\n" "$USER" "$(date +%s)" "$RANDOM"
+ fi
+ done > p