Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

52 lines (40 sloc) 1.778 kb
#!/bin/bash
for file in example_bots/*.jar
do
player_1_counter=0
player_1_turn_counter=0
player_2_counter=0
player_2_turn_counter=0
draw_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
if [ "$RES2" = "2" ] ; then
player_2_counter=`expr $player_2_counter + 1`
player_2_turn_counter=`expr $player_2_turn_counter + $TURN`
else
draw_counter=`expr $draw_counter + 1`
fi
fi
maps_played=`expr $maps_played + 1`
echo "map: $i - Winner: $RES2 - Turns: $TURN"
#sleep 1
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 : $player_1_counter/$maps_played, avg turns: $avg_player_1_turn_counter"
echo "tied against $file : $draw_counter/$maps_played"
done
Jump to Line
Something went wrong with that request. Please try again.