From 5017d17e59df10384b36b242b26d120034c5b15a Mon Sep 17 00:00:00 2001 From: Calcitem Date: Sun, 25 Oct 2020 02:36:22 +0800 Subject: [PATCH] =?UTF-8?q?analyze:=20=E6=89=93=E5=8D=B0=E8=83=9C=E7=8E=87?= =?UTF-8?q?=E5=B9=B6=E4=BF=9D=E7=95=992=E4=BD=8D=E5=B0=8F=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/thread.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/thread.cpp b/src/thread.cpp index 03704a0e..695c8143 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -20,6 +20,7 @@ #include #include // For std::count +#include #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;