forked from apinkin/planetwars-python-kit
-
Notifications
You must be signed in to change notification settings - Fork 1
/
batch.sh
executable file
·44 lines (33 loc) · 1.51 KB
/
batch.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
#!/bin/bash
for file in example_bots/*Bot.jar
do
player_1_counter=0
player_1_turn_counter=0
player_2_counter=0
player_2_turn_counter=0
maps_played=0
echo "Bot: $file"
for i in {1..100}
do
RES=`java -jar tools/PlayGame.jar maps/map$i.txt 1000 200 log.txt "java -jar $file" "python MyBot.py" 2>&1 | tail -n 3 | grep "Turn\|Player"`
TURN=`echo $RES | grep -i turn | sed 's/.*urn \([0-9]*\).*/\1/'`
RES2=`echo $RES | grep -i player | sed 's/.*ayer \([0-9]*\).*/\1/'`
if [ "$RES2" = "1" ] ; then
player_1_counter=`expr $player_1_counter + 1`
player_1_turn_counter=`expr $player_1_turn_counter + $TURN`
else
player_2_counter=`expr $player_2_counter + 1`
player_2_turn_counter=`expr $player_2_turn_counter + $TURN`
fi
maps_played=`expr $maps_played + 1`
echo "map: $i - Winner: $RES2 - Turns: $TURN"
done
if [ "$player_2_counter" != "0" ] ; then
avg_player_2_turn_counter=`expr $player_2_turn_counter / $player_2_counter`
fi
if [ "$player_1_counter" != "0" ] ; then
avg_player_1_turn_counter=`expr $player_1_turn_counter / $player_1_counter`
fi
echo "won against $file : $player_2_counter/$maps_played, avg turns: $avg_player_2_turn_counter"
echo "lost against $file lost : $player_1_counter/$maps_played, avg turns: $avg_player_1_turn_counter"
done