analyze: 打印胜率并保留2位小数
This commit is contained in:
parent
3fa33fc9df
commit
5017d17e59
|
@ -20,6 +20,7 @@
|
|||
#include <cassert>
|
||||
|
||||
#include <algorithm> // For std::count
|
||||
#include <iomanip>
|
||||
#include "movegen.h"
|
||||
#include "search.h"
|
||||
#include "thread.h"
|
||||
|
@ -356,7 +357,21 @@ void Thread::analyze(Color c)
|
|||
cout << "轮到白方行棋" << endl;
|
||||
}
|
||||
|
||||
cout << "比分: " << nbwin << " : " << nwwin << " : " << ndraw << endl;
|
||||
int total = nbwin + nwwin + ndraw;
|
||||
float bwinrate, wwinrate, drawrate;
|
||||
|
||||
if (total == 0) {
|
||||
bwinrate = 0;
|
||||
wwinrate = 0;
|
||||
drawrate = 0;
|
||||
} else {
|
||||
bwinrate = (float)nbwin * 100 / total;
|
||||
wwinrate = (float)nwwin * 100 / total;
|
||||
drawrate = (float)ndraw * 100 / total;
|
||||
}
|
||||
|
||||
cout << "比分: " << nbwin << " : " << nwwin << " : " << ndraw << "\ttotal: " << total << endl;
|
||||
cout << fixed << setprecision(2) << bwinrate << "% : " << wwinrate << "% : " << drawrate << "%" << endl;
|
||||
|
||||
out:
|
||||
cout << endl << endl;
|
||||
|
|
Loading…
Reference in New Issue