From 35c11ded6defeb1778aa4c82ec102c864a54ca9e Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Mon, 27 Apr 2015 15:17:25 +0200 Subject: Run multiple games per couple in a competition --- fullcompMT.sh | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'fullcompMT.sh') 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 -- cgit v1.2.3-54-g00ecf