#!/bin/sh
PRG_1=./player_A
PRG_2=./player_B
GAME_DIR=new_stats
NB_GAMES_PER_SIDE=10
NBL=6
NBC=4
if [ -d ${GAME_DIR} ]
then
echo "GAME_DIR ever here"
exit 0
else
mkdir ${GAME_DIR}
fi
if [ ! -e ${PRG_1} ]
echo "PRG_1 is missing"
if [ ! -e ${PRG_2} ]
echo "PRG_2 is missing"
pike run_many_games.pike -f ${PRG_1} -s ${PRG_2} -o ${GAME_DIR} -n ${NB_GAMES_PER_SIDE} -l ${NBL} -c ${NBC} 2> ${GAME_DIR}/log1.txt 1>&2
pike run_many_games.pike -f ${PRG_2} -s ${PRG_1} -o ${GAME_DIR} -n ${NB_GAMES_PER_SIDE} -l ${NBL} -c ${NBC} 2> ${GAME_DIR}/log2.txt 1>&2
{
echo " ================"
echo " NB_GAMES_PER_SIDE ${NB_GAMES_PER_SIDE}"
echo " NBL ${NBL}"
echo " NBC ${NBC}"
echo ""
echo " number of wins"
} > ${GAME_DIR}/resume.txt
STR_WIN1=$(${PRG_1} win)
NB_WIN1=$(grep -c "${STR_WIN1}" ${GAME_DIR}/scores.txt)
echo " ${PRG_1} is ${NB_WIN1}" >> ${GAME_DIR}/resume.txt
STR_WIN2=$(${PRG_2} win)
NB_WIN2=$(grep -c "${STR_WIN2}" ${GAME_DIR}/scores.txt)
echo " ${PRG_2} is ${NB_WIN2}"
} >> ${GAME_DIR}/resume.txt