90 opening=$((opening + 1))
91 opening=$((opening % 3))
93 if [ $verbosity -ge 2 ]; then
94 echo
"opening $opening"
96 newchoice=$((guess+1));
97 newchoice=$((newchoice % 3));
98 while [ $newchoice -eq $opening ];
do
99 newchoice=$((newchoice + 1));
100 newchoice=$((newchoice % 3));
105##! Number of wins for player A
107##! Number of wins for player B
109##! Position of the prize
113##! Counter for the number of rounds already done.
115##! Counts how often the random number was 0. Used for statistics at the end of the script.
117##! Counts how often the random number was 1. Used for statistics at the end of the script.
119##! Counts how often the random number was 2. Used for statistics at the end of the script.
121while [
$i -le $numrounds ];
do
122 prizepos=$(($RANDOM % 3));
124 guess=$(($RANDOM % 3));
128 if [ $verbosity -ge 1 ]; then
129 echo
"prize: $prizepos a: $guess b: $newguess"
130 echo
"---------------------------------------"
138 if [[ $verbosity -ge 1 && $numrounds -lt 1000 ]]; then
139 apercent=$((winsa*100/i))
140 bpercent=$((winsb*100/i))
141 echo
"keep: $winsa $apercent% swap: $winsb $bpercent%";
143 if [ $((i%1000)) -eq 0 ]; then
144 apercent=$((winsa*100/i))
145 bpercent=$((winsb*100/i))
146 if [ $verbosity -ge 1 ]; then
147 echo
"keep: $winsa $apercent% swap: $winsb $bpercent%";
149 print
"progress: $(((i*1000/numrounds)/10)).$(((i*1000/numrounds)%10))%";