#! /bin/bash # Simple test campaign: # free awale vs/ pyAwale. # 'test_freeawale.py' program TEST_FREEAWALE="test_freeawale.py" # Path to free awale program FREEAWALE_PROGRAM="/usr/local/bin/awale" #FREEAWALE_PROGRAM="/home/mickey/games/puzzle/awale-1.2/src/awale" # # Print usage. # $1: prog name # usage () { echo "Usage: `basename $1` -a -l ..." echo "" echo "Test free awale vs/ pyAwale." echo "" echo "Options:" echo " -h, --help print program options" echo " -a, --algos list of algos to test" echo " -l, --level max level for each algo" echo "" echo "Exemple:" echo " `basename $1` -a 'bfs maxi minimax negamax' -l 3 " echo "" exit 0 } # Filter options: # Note that we use `"$@"' to let each command-line parameter expand to a # separate word. The quotes around `$@' are essential! # We need TEMP as the `eval set --' would nuke the return value of getopt. TEMP=`getopt -o ha:l: \ -l help-long,algos-long:,level-long \ -n 'test_freeawale.bash' -- "$@"` if [ $? != 0 ]; then echo "Terminating..." >&2 exit 1 fi # Note the quotes around `$TEMP': they are essential! eval set -- "$TEMP" ALGOS="bfs maxi minimax negamax" MAX_LEVEL=3 while true; do case "$1" in -h|--help-long) usage $0; shift;; -a|--algos-long) ALGOS="$2"; shift 2;; -l|--level-long) MAX_LEVEL=$2; shift 2;; --) shift; break;; *) echo "Internal error!"; exit 1;; esac done #echo "Remaining arguments:" #for arg; do echo '--> '"\`$arg'"; done if [ "${ALGOS}" == "" ]; then echo "Missing algos list!" usage $0 fi if [ "${MAX_LEVEL}" == "" ]; then echo "Missing max level!" usage $0 fi #if [ $# = 0 ]; then # echo "Missing arguments!" # usage $0 #fi # Process start here. # Loop on all algos types for ALGO in ${ALGOS}; do # Loop on all levels LEVEL=1 while [ ${LEVEL} -le ${MAX_LEVEL} ]; do # Execute command echo "'${ALGO}' level ${LEVEL}: 5 tries, free awale begin (south)" python -O ${TEST_FREEAWALE} --algo ${ALGO} --level ${LEVEL} --run 5 --begin -p ${FREEAWALE_PROGRAM} -o echo "'${ALGO}' level ${LEVEL}: 3 tries, pyawale begin (north)" python -O ${TEST_FREEAWALE} --algo ${ALGO} --level ${LEVEL} --run 3 -p ${FREEAWALE_PROGRAM} -o LEVEL=`expr ${LEVEL} + 1` # next done done