diff --git a/README.md b/README.md index c506f82..84d967a 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ 请参考gtp指令手册(http://www.lysator.liu.se/~gunnar/gtp/)或者使用sabaki等图形界面工具 2. 如果使用zen6的zen.dll,需要设置参数 gtp4zen.exe -z6 3. gtp4zen.exe所在的文件夹如果存在gtp4zen.lua,命令行-T参数自动失效并使用gtp4zen.lua的时间控制, -这个脚本用于精细化时间控制,如果不明白用途可以★★删除★★gtp4zen.lua,默认★★文件存在并生效★★ +这个脚本用于精细化时间控制,如果不明白用途可以删除gtp4zen.lua,文件存在即表示生效 4. gtp4zen.exe --help输出帮助,-t是线程数(默认和cpu核数量相同),-T最大思考时间,-s最大计算步数,-l指定log文件,-d会输出调试信息到gtpshell,帮助信息如下: C:\Users\clock\Desktop>gtp4zen.exe --help diff --git a/gtp4zen/gtp4zen.cpp b/gtp4zen/gtp4zen.cpp index e70d04b..e83da02 100644 --- a/gtp4zen/gtp4zen.cpp +++ b/gtp4zen/gtp4zen.cpp @@ -24,6 +24,7 @@ float g_think_level_1 = 1.0; float g_think_level_2 = 1.0; int g_think_level_0 = 1; int g_resign = 10; +bool g_chinese_rule = true; #ifdef _DEBUG string g_logfile = "gtp4zen_log.txt"; @@ -70,6 +71,7 @@ int _tmain(int argc, _TCHAR* argv[]) ("logfile,l", value(), "Enable logging and set the log file. (default none)") ("logfilenametime,L", "Add timestamp after log filename. (default off)") ("debug,d", "Enable debug output to gtp shell. (default off)") + ("jpn_rules", "Set to Japanese rules. (default Chinese rules)") ; /* ѡ -t -T -M -m -l -k -w -s -f @@ -141,6 +143,9 @@ int _tmain(int argc, _TCHAR* argv[]) if (vm.count("logfile")) { g_logfile = vm["logfile"].as(); } + if (vm.count("jpn_rules")) { + g_chinese_rule = false; + } if (error_options) { cerr << "ERROR: unknown, check by gtp4zen --help" << endl; diff --git a/gtp4zen/stdafx.h b/gtp4zen/stdafx.h index ac2455c..0c9c4c5 100644 --- a/gtp4zen/stdafx.h +++ b/gtp4zen/stdafx.h @@ -37,6 +37,7 @@ extern float g_think_level_1; extern float g_think_level_2; extern int g_think_level_0; extern int g_resign; +extern bool g_chinese_rule; extern int __ansi2num(char ch); extern std::string __num2ansi(int x, int y, int boardsize); diff --git a/gtp4zen/zen6gtp.cpp b/gtp4zen/zen6gtp.cpp index 4ea945a..7f1c83d 100644 --- a/gtp4zen/zen6gtp.cpp +++ b/gtp4zen/zen6gtp.cpp @@ -102,25 +102,48 @@ std::string CZen6Gtp::score() { int territory[19][19]; ((_zen_dll_proxy*)m_proxy)->ZenGetTerritoryStatictics(territory); - float moku_w = ((_zen_dll_proxy*)m_proxy)->ZenGetNumWhitePrisoners(), moku_b = ((_zen_dll_proxy*)m_proxy)->ZenGetNumBlackPrisoners(); - for (int j = 0; j < ((_zen_dll_proxy*)m_proxy)->m_boardsize; ++j) + float moku_w = 0, moku_b = 0; + if (g_chinese_rule) { - for (int i = 0; i < ((_zen_dll_proxy*)m_proxy)->m_boardsize; ++i) + for (int j = 0; j < ((_zen_dll_proxy*)m_proxy)->m_boardsize; ++j) { - int color = ((_zen_dll_proxy*)m_proxy)->ZenGetBoardColor(i, j); - if (territory[j][i] <= -500) + for (int i = 0; i < ((_zen_dll_proxy*)m_proxy)->m_boardsize; ++i) { - if (color == 2) - moku_w += 2; - else if (color == 0) + int color = ((_zen_dll_proxy*)m_proxy)->ZenGetBoardColor(i, j); + if (territory[j][i] <= -500) + { moku_w += 1; + } + else if (territory[j][i] >= 500) + { + moku_b += 1; + } } - else if (territory[j][i] >= 500) + } + } + else + { + moku_w = ((_zen_dll_proxy*)m_proxy)->ZenGetNumWhitePrisoners(); + moku_b = ((_zen_dll_proxy*)m_proxy)->ZenGetNumBlackPrisoners(); + for (int j = 0; j < ((_zen_dll_proxy*)m_proxy)->m_boardsize; ++j) + { + for (int i = 0; i < ((_zen_dll_proxy*)m_proxy)->m_boardsize; ++i) { - if (color == 1) - moku_b += 2; - else if (color == 0) - moku_b += 1; + int color = ((_zen_dll_proxy*)m_proxy)->ZenGetBoardColor(i, j); + if (territory[j][i] <= -500) + { + if (color == 2) + moku_w += 2; + else if (color == 0) + moku_w += 1; + } + else if (territory[j][i] >= 500) + { + if (color == 1) + moku_b += 2; + else if (color == 0) + moku_b += 1; + } } } } diff --git a/gtp4zen/zen7gtp.cpp b/gtp4zen/zen7gtp.cpp index 8910492..a36fecf 100644 --- a/gtp4zen/zen7gtp.cpp +++ b/gtp4zen/zen7gtp.cpp @@ -103,25 +103,48 @@ std::string CZen7Gtp::score() { int territory[19][19]; ((_zen_dll_proxy*)m_proxy)->ZenGetTerritoryStatictics(territory); - float moku_w = ((_zen_dll_proxy*)m_proxy)->ZenGetNumWhitePrisoners(), moku_b = ((_zen_dll_proxy*)m_proxy)->ZenGetNumBlackPrisoners(); - for (int j = 0; j < ((_zen_dll_proxy*)m_proxy)->m_boardsize; ++j) + float moku_w = 0, moku_b = 0; + if (g_chinese_rule) { - for (int i = 0; i < ((_zen_dll_proxy*)m_proxy)->m_boardsize; ++i) + for (int j = 0; j < ((_zen_dll_proxy*)m_proxy)->m_boardsize; ++j) { - int color = ((_zen_dll_proxy*)m_proxy)->ZenGetBoardColor(i, j); - if (territory[j][i] <= -500) + for (int i = 0; i < ((_zen_dll_proxy*)m_proxy)->m_boardsize; ++i) { - if (color == 2) - moku_w += 2; - else if (color == 0) + int color = ((_zen_dll_proxy*)m_proxy)->ZenGetBoardColor(i, j); + if (territory[j][i] <= -500) + { moku_w += 1; + } + else if (territory[j][i] >= 500) + { + moku_b += 1; + } } - else if (territory[j][i] >= 500) + } + } + else + { + moku_w = ((_zen_dll_proxy*)m_proxy)->ZenGetNumWhitePrisoners(); + moku_b = ((_zen_dll_proxy*)m_proxy)->ZenGetNumBlackPrisoners(); + for (int j = 0; j < ((_zen_dll_proxy*)m_proxy)->m_boardsize; ++j) + { + for (int i = 0; i < ((_zen_dll_proxy*)m_proxy)->m_boardsize; ++i) { - if (color == 1) - moku_b += 2; - else if (color == 0) - moku_b += 1; + int color = ((_zen_dll_proxy*)m_proxy)->ZenGetBoardColor(i, j); + if (territory[j][i] <= -500) + { + if (color == 2) + moku_w += 2; + else if (color == 0) + moku_w += 1; + } + else if (territory[j][i] >= 500) + { + if (color == 1) + moku_b += 2; + else if (color == 0) + moku_b += 1; + } } } }