Skip to content

Commit 0ce7de0

Browse files
committed
modify record.sh
1 parent 3738487 commit 0ce7de0

File tree

1 file changed

+36
-27
lines changed

1 file changed

+36
-27
lines changed

script/record.sh

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
GAMES=10
44
BLACK=0
55
WHITE=0
6-
PARALLEL_CNT=0
7-
PARALLEL_TIME=0
8-
SERIAL_CNT=0
9-
SERIAL_TIME=0
6+
PLAYER_CNT=0
7+
PLAYER_TIME=0
8+
ENV_CNT=0
9+
ENV_TIME=0
1010

1111
PROJECT_ROOT=$(pwd | rev | cut -d / -f 1 --complement | rev )
1212
PROJECT_ROOT=$PROJECT_ROOT/build
@@ -16,42 +16,51 @@ cd $PROJECT_ROOT
1616

1717
for i in $(seq 1 $GAMES);
1818
do
19-
# make clean && make; ./mcts > result.txt
20-
./mcts > result.txt
19+
./mcts $@ > result.txt
2120

22-
game_parallel_cnt=`cat result.txt | grep "Parallel count:" | cut -d ":" -f2 | awk 'BEGIN{cnt=0} {cnt+=$1} END{print cnt}' `
23-
game_serial_cnt=`cat result.txt | grep "Serial count:" | cut -d ":" -f2 | awk 'BEGIN{cnt=0} {cnt+=$1} END{print cnt}' `
21+
game_player_cnt=`sed -n '/Player/,/Envir/p' tesst | grep "Total search count: " | cut -d ":" -f2 | cut -d " " -f2`
22+
game_env_cnt=`sed -n '/Envir/,/times/p' tesst | grep "Total search count: " | cut -d ":" -f2 | cut -d " " -f2`
2423

25-
PARALLEL_CNT=`echo $PARALLEL_CNT + $game_parallel_cnt | bc`
26-
SERIAL_CNT=`echo $SERIAL_CNT + $game_serial_cnt | bc`
24+
PLAYER_CNT=`echo $PLAYER_CNT + $game_player_cnt | bc`
25+
ENV_CNT=`echo $ENV_CNT + $game_env_cnt | bc`
2726

28-
game_parallel_time=`cat result.txt | grep "Total time cost: " | head -n 1 | grep -Eo '[0-9]+([.][0-9]+)?'`
29-
game_serial_time=`cat result.txt | grep "Total time cost: " | tail -n 1 | grep -Eo '[0-9]+([.][0-9]+)?'`
27+
game_player_time=`sed -n '/Player/,/Envir/p' result.txt | grep "Total time cost: " | cut -d ":" -f2 | cut -d " " -f2`
28+
game_env_time=`sed -n '/Envir/,/times/p' tesst | grep "Total time cost: " | cut -d ":" -f2 | cut -d " " -f2`
3029

31-
PARALLEL_TIME=`echo $PARALLEL_TIME + $game_parallel_time | bc`
32-
SERIAL_TIME=`echo $SERIAL_TIME + $game_serial_time | bc`
30+
PLAYER_TIME=`echo $PLAYER_TIME + $game_player_time | bc`
31+
ENV_TIME=`echo $ENV_TIME + $game_env_time | bc`
3332

3433
winner=`cat result.txt | grep "winner:" | cut -d ":" -f2`
35-
if [ $winner -eq 0 ]; then
34+
if [ $winner = "Black" ]; then
3635
BLACK=$((BLACK+1))
37-
else
36+
elif [ $winner = "White" ]; then
3837
WHITE=$((WHITE+1))
38+
else
39+
BLACK=`echo $BLACK + 0.5 | bc`
40+
WHITE=`echo $WHITE + 0.5 | bc`
3941
fi
4042
done
41-
42-
AVG_Parallel_step=`echo $PARALLEL_CNT/$PARALLEL_TIME | bc -l`
43-
AVG_Serial_step=`echo $SERIAL_CNT/$SERIAL_TIME | bc -l `
44-
45-
echo "\n\n\nIn ${GAMES} Games"
43+
AVG_Player_step=`echo $PLAYER_CNT/$PLAYER_TIME | bc -l`
44+
AVG_Env_step=`echo $ENV_CNT/$ENV_TIME | bc -l `
45+
46+
echo "In ${GAMES} Games"
47+
# echo `cat result.txt | sed -n '/simulationCount:/,/+/p' | head -n -1`
48+
echo `cat result.txt | sed '1,1!d'`
49+
echo `cat result.txt | sed '2,2!d'`
50+
echo `cat result.txt | sed '3,3!d'`
51+
echo `cat result.txt | sed '4,4!d'`
52+
echo `cat result.txt | sed '5,5!d'`
53+
echo
54+
echo
4655
echo "The average win rate of black is ${BLACK}/${GAMES}"
4756

48-
echo "The total simulation count of parallel is ${PARALLEL_CNT}"
49-
echo "The total simulation count of serial is ${SERIAL_CNT}"
57+
echo "The total simulation count of black is ${PLAYER_CNT}"
58+
echo "The total simulation count of white is ${ENV_CNT}"
5059

51-
echo "The total time of parallel is ${PARALLEL_TIME}"
52-
echo "The total time of serial is ${SERIAL_TIME}"
60+
echo "The total time of black is ${PLAYER_TIME}"
61+
echo "The total time of white is ${ENV_TIME}"
5362

54-
echo "The average steps of Parallel is $AVG_Parallel_step steps/(ms)"
55-
echo "The average steps of serial is $AVG_Serial_step steps/(ms)"
63+
echo "The average steps of black is $AVG_Player_step steps/(ms)"
64+
echo "The average steps of white is $AVG_Env_step steps/(ms)"
5665

5766

0 commit comments

Comments
 (0)