aboutsummaryrefslogtreecommitdiff
path: root/fullcompMT.sh
diff options
context:
space:
mode:
authortomsmeding <hallo@tomsmeding.nl>2015-04-27 15:17:25 +0200
committertomsmeding <hallo@tomsmeding.nl>2015-04-27 15:17:25 +0200
commit35c11ded6defeb1778aa4c82ec102c864a54ca9e (patch)
treeb9745b63e6773bfcd90b9702b54d59a9224b1ff7 /fullcompMT.sh
parentf90b2aff40e24901cf2146f46b052bd42cf0a160 (diff)
Run multiple games per couple in a competition
Diffstat (limited to 'fullcompMT.sh')
-rwxr-xr-xfullcompMT.sh17
1 files changed, 11 insertions, 6 deletions
diff --git a/fullcompMT.sh b/fullcompMT.sh
index 7f4084e..7bb4665 100755
--- a/fullcompMT.sh
+++ b/fullcompMT.sh
@@ -1,5 +1,6 @@
#!/usr/bin/env bash
BINARIES="./gluon ./neutrino ./randino ./charm"
+NUMGAMES=5
if [[ ! -e competitions ]]; then
mkdir competitions || exit 1
@@ -50,7 +51,7 @@ fi
-if [[ isatty ]]; then
+if [[ -t 1 ]]; then
function green {
printf '\x1B[33m%s\x1B[0m' $1
}
@@ -67,16 +68,19 @@ for p1 in $BINARIES; do
[[ $p1 == $p2 ]] && continue
p1pretty=$(echo "$p1" | sed 's/[^a-zA-Z0-9 ]//g')
p2pretty=$(echo "$p2" | sed 's/[^a-zA-Z0-9 ]//g')
- COMPFILE="competitionstubs/game_${p1pretty}_vs_${p2pretty}.sh"
- cat >"$COMPFILE" << EOF
+ for i in $(seq 1 $NUMGAMES); do
+ FNAMEFORMAT="game_${p1pretty}_vs_${p2pretty}.$(printf '%03d' $i)"
+ COMPFILE="competitionstubs/$FNAMEFORMAT.sh"
+ CLOGFILE="competitions/$FNAMEFORMAT.txt"
+ cat >"$COMPFILE" << EOF
#!/usr/bin/env bash
-printf "%s\n%s\n" $p1 $p2 | ./competition.py -q -
+printf "%s\n%s\n" $p1 $p2 | ./competition.py -qc "$CLOGFILE" -
status=$?
if [[ \$status != 0 ]]; then
echo \$(date +"$DATE_FMT") "$p1 - $p2 : ERROR $status (0-0)" >$FIFONAME
exit 1
fi
-lastline=\$(tail -n1 "competitions/game_${p1pretty}_vs_${p2pretty}.txt")
+lastline=\$(tail -n1 "$CLOGFILE")
if [[ "\$lastline" == "P1 won" ]]; then
echo \$(date +"$DATE_FMT") $(green "$p1") "- $p2 : WIN - LOSS (3-1)" >$FIFONAME
elif [[ "\$lastline" == "P2 won" ]]; then
@@ -85,7 +89,8 @@ elif [[ "\$lastline" == "Tie" ]]; then
echo \$(date +"$DATE_FMT") "$p1" $(green -) "$p2 : TIE (1-1)" >$FIFONAME
fi
EOF
- chmod +x $COMPFILE
+ chmod +x $COMPFILE
+ done
done
done