-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_teams
executable file
·67 lines (55 loc) · 1.85 KB
/
run_teams
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
#!/bin/bash
if [ ! -f ./minimax_game2 ]; then
make minimax_game2
fi
if [ $1 ]; then
games=$1
else
games=10
fi
NUMBERS="012 013 014 015 023 024 025 034 035 045 123 124 125 134 135 145 234 235 245 345"
margin=0.1 # call with 10 percent close
margin=$(echo "scale=4; $games*$margin" | bc)
team_1_edge_points=0
team_2_edge_points=0
even_steven=0
for n1 in `echo $NUMBERS`
do
for n2 in `echo $NUMBERS`
do
echo -n "."
./run_games2 $games "$n1$n2" > temp_team_results
cur_wins_1=` cat temp_team_results | perl -n -e'/(\d+)\s+Team 1 wins!!/ && print $1'`
cur_wins_2=` cat temp_team_results | perl -n -e'/(\d+)\s+Team 2 wins!!/ && print $1'`
team_1_margin=$(echo "$(($cur_wins_1-$cur_wins_2)) < $margin && $(($cur_wins_1-$cur_wins_2)) > 0" | bc)
team_2_margin=$(echo "$(($cur_wins_2-$cur_wins_1)) < $margin && $(($cur_wins_2-$cur_wins_1)) > 0" | bc)
if [ ! $(($cur_wins_1-$cur_wins_2)) -eq $games ]; then
echo
echo ./run_games2 $games "$n1$n2"
echo "Team 1: " $cur_wins_1 " Team 2: " $cur_wins_2 " diff: " $(($cur_wins_1-$cur_wins_2))
if [ $(($team_1_margin+$team_2_margin)) -gt 0 ]; then
even_steven=$(($even_steven+1))
echo "Teams were even"
else
if [ $cur_wins_1 -gt $cur_wins_2 ]; then
team_1_edge_points=$(($team_1_edge_points+1))
else
team_2_edge_points=$(($team_2_edge_points+1))
echo "Team 2 had edge"
fi
fi
fi
wins_1=$(($wins_1+$cur_wins_1))
wins_2=$(($wins_2+$cur_wins_2))
ties=$(($ties+` cat temp_team_results | perl -n -e'/(\d+)\s+ties!!/ && print $1'`))
done
done
echo
echo "--------------------------"
echo -e "total wins\t" $wins_1 "\t for Team 1"
echo -e "edge points\t" $team_1_edge_points "\t for Team 1"
echo -e "total wins\t" $wins_2 "\t for Team 2"
echo -e "edge points\t" $team_2_edge_points "\t for Team 2"
echo -e "total ties\t" $ties
echo -e "even stevens\t" $even_steven
exit 0