aboutsummaryrefslogtreecommitdiff
path: root/fullcompMT.sh
diff options
context:
space:
mode:
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