This repository has been archived by the owner on Dec 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
loop.sh
executable file
·110 lines (91 loc) · 2.7 KB
/
loop.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/bin/bash
set -eu
source .env
run() {
challenge=$1
outfile=$2
args="SIMULATOR_ARGS_C"$challenge
args=${!args}
(cd ../simulator; ./simulator $args) >/dev/null 2>&1 &
sleep 1
if [ "$ENABLE_VIEWER" != 0 ]; then
(cd ../Viewer; ./Viewer --autoconnect) >/dev/null 2>&1 &
sleep 1
fi
./run.sh -c$challenge -f $outfile >/dev/null
killall simulator >/dev/null 2>&1 || true
killall Viewer >/dev/null 2>&1 || true
}
silent_mode=0
while getopts "c:s" op
do
case $op in
"c")
challenge=$OPTARG
;;
"s")
silent_mode=1
;;
default)
echo "ERROR: unknown parameter"
;;
esac
done
shift $(($OPTIND-1))
outfile="solution"
case $challenge in
1)
for n in $(seq 1 $NUM_RUNS)
do
if [ "$silent_mode" != 0 ]; then
run $challenge $outfile >/dev/null 2>&1
else
echo "Run $n:"
run $challenge $outfile
fi
done
;;
2|3)
for n in $(seq 1 $NUM_RUNS)
do
if [ "$silent_mode" != 0 ]; then
run $challenge $outfile >/dev/null 2>&1
./test-run.sh -c$challenge -f$outfile >/dev/null 2>&1
else
echo "Run $n:"
run $challenge $outfile
./test-run.sh -c$challenge -f$outfile
fi
done
;;
4)
# remove old scores and failed runs
rm $SCORES_FILE >/dev/null 2>&1 || true
rm -r $FAILED_DIR >/dev/null 2>&1 || true
for n in $(seq 1 $NUM_RUNS)
do
if [ "$silent_mode" != 0 ]; then
run $challenge $outfile >/dev/null 2>&1
./test-run.sh -c$challenge -f$outfile >/dev/null 2>&1
else
echo "Run $n:"
run $challenge $outfile
./test-run.sh -c$challenge -f$outfile
fi
done
# calculate the average score for both map and path
total_map_score=0
total_path_score=0
while IFS= read -r line
do
score=$(echo $line | cut -d' ' -f1)
total_map_score=$(echo "scale=2;$total_map_score + $score" | bc)
score=$(echo $line | cut -d' ' -f2)
total_path_score=$(echo "scale=2;$total_path_score + $score" | bc)
done < scores.txt
total_map_score=$(echo "scale=2;$total_map_score / $NUM_RUNS" | bc -l)
total_path_score=$(echo "scale=2;$total_path_score / $NUM_RUNS" | bc -l)
echo "Average map score: $total_map_score"
echo "Average path score: $total_path_score"
;;
esac