-
Notifications
You must be signed in to change notification settings - Fork 0
/
pool_test.sh
executable file
·75 lines (61 loc) · 1.88 KB
/
pool_test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# **************************************************************************** #
# #
# ::: :::::::: #
# pool_test.sh :+: :+: :+: #
# +:+ +:+ +:+ #
# By: jle-mene <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2016/12/08 09:31:13 by jle-mene #+# #+# #
# Updated: 2016/12/14 10:50:53 by jle-mene ### ########.fr #
# #
# **************************************************************************** #
#!/bin/bash
trap ctrl_c INT
AI=./players/wyki.filler
RESULT=./pool_test_result.txt
OUTPUT=/tmp/test.txt
function ctrl_c
{
echo "Aborting..."
exit 1;
}
function launch_vm
{
echo "Map $1" >> $RESULT
for I in {1..5}
do
./filler_vm -f ./maps/map$1 -p1 $AI -p2 $line > $OUTPUT
tail -2 $OUTPUT >> $RESULT
SCORE1=$(tail -2 $OUTPUT | sed -n 1p)
SCORE1=${SCORE1##* }
SCORE2=$(tail -1 $OUTPUT)
SCORE2=${SCORE2##* }
if [ $SCORE1 -gt $SCORE2 ]
then
echo "$I : \033[92;1mWIN\033[0m" >> $RESULT
else
echo "$I : \033[91;1mLOOSE\033[0m" >> $RESULT
fi
done
}
function main
{
if [ ${PWD##*/} != 'resources' ]
then
echo 'Need to be launched in resources folder !'
echo ${PWD##*/}
exit 1
fi
echo "" > $RESULT
find ./players -name '*.filler' | while read line
do
echo "$line"
echo "########## TEST ##########" >> $RESULT
echo "Test $(basename $AI) vs. $(basename $line)" >> $RESULT
launch_vm '00'
launch_vm '01'
launch_vm '02'
echo "##########################" >> $RESULT
done
}
main