Skip to content

Commit

Permalink
fix set_free_handicap, load "zen6.dll" and "zen7.dll" by default
Browse files Browse the repository at this point in the history
  • Loading branch information
breakwa11 committed Feb 20, 2019
1 parent 6a935d7 commit a979497
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 24 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

使用说明:

1. 把zen7的zen.dll拷贝到gtp4zen.exe所在的文件夹,运行即可,只需要gtp4zen.exe和zen.dll这2个文件
1. 把zen7的zen.dll拷贝到gtp4zen.exe所在的文件夹,重命名为zen7.dll,再运行即可,只需要gtp4zen.exe和zen7.dll这2个文件
请参考gtp指令手册(http://www.lysator.liu.se/~gunnar/gtp/)或者使用sabaki等图形界面工具
2. 如果使用zen6的zen.dll,需要设置参数 gtp4zen.exe -z6
2. 如果使用zen6的zen.dll,需要重命名为zen6.dll,且设置参数 gtp4zen.exe -z6
3. gtp4zen.exe所在的文件夹如果存在gtp4zen.lua,命令行-T参数自动失效并使用gtp4zen.lua的时间控制,
这个脚本用于精细化时间控制,如果不明白用途可以删除gtp4zen.lua,文件存在即表示生效
4. gtp4zen.exe --help输出帮助,-t是线程数(默认和cpu核数量相同),-T最大思考时间,-s最大计算步数,-l指定log文件,-d会输出调试信息到gtpshell,帮助信息如下:
Expand All @@ -15,7 +15,7 @@ C:\Users\clock\Desktop>gtp4zen.exe --help

Options:
-h [ --help ] Show all allowed options.
-z [ --zenverion ] arg Version of zen.dll, must be 6 or 7. (default 7)
-z [ --zenverion ] arg Version of dll, must be 6 or 7. (default 7)
-t [ --threads ] arg Set the number of threads to use. (default
CPU_CORES)
-T [ --maxtime ] arg Set the max time for one move. (default 10 seconds)
Expand Down
30 changes: 16 additions & 14 deletions bin/release/说明.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
1.把zen7的zen.dll拷贝到gtp4zen.exe所在的文件夹,运行即可,只需要gtp4zen.exe和zen.dll这2个文件
1.把zen6或zen7的zen.dll拷贝到gtp4zen.exe所在的文件夹,并重命名为zen6.dll或zen7.dll,运行即可,只需要gtp4zen.exe和zen.dll这2个文件
请参考gtp指令手册(http://www.lysator.liu.se/~gunnar/gtp/)或者使用sabaki等图形界面工具


Expand All @@ -9,29 +9,31 @@
3.gtp4zen.exe --help输出帮助,-t是线程数(默认和cpu核数量相同),-T最大思考时间,
-s最大计算步数,-l指定log文件,-d会输出信息到gtpshell,如下:
C:\Users\clock\Desktop>gtp4zen.exe --help
gtp4zen by yongjian(QQ group:14501533, mail:[email protected])
www.weiqiba.com(v0.3.3, compile: 2017-11-27 19:10:33)
Usage: gtp4zen -z 7 -t 4 -T 10 -s 10000 -l mylog.txt -L -d -i 1000
Options:
-h [ --help ] Show all allowed options.
-z [ --zenverion ] arg Version of zen.dll, must be 6 or 7. (default 7)
-z [ --zenverion ] arg Version of dll, must be 6 or 7. (default 7)
-t [ --threads ] arg Set the number of threads to use. (default
CPU_CORES)
-T [ --maxtime ] arg Set the max time for one move. (default 10 seconds)
-s [ --strength ] arg Set the playing strength. (default 10000)
-s [ --strength ] arg Set the max playout. (default 10000)
-i [ --ithink ] arg thinking interval, only set 100 when play cgos.
(default 1000ms)
(default 100)
-n [ --ilevel0 ] arg factor0. (default 1)
-o [ --ilevel1 ] arg factor1. (default 1)
-p [ --ilevel2 ] arg factor2. (default 1)
-r [ --resign ] arg resign. (default 10)
-l [ --logfile ] arg Enable logging and set the log file. (default none)
-L [ --logfilenametime ] Add timestamp after log filename. (default off)
-d [ --debug ] Enable debug output to gtp shell. (default off)

其中 n,o,p 三个参数由你使用zen6还是zen7决定其含义,具体可参考Github项目GoAIRatings
以上3个参数如不指定,棋力将达不到预想值。
如果你单纯需要最强的棋力,如果是zen6,设置-n1 -o1 -p1(即默认值),如果是zen7,设置-n3 -o1 -p0.75
参数 r 设置胜率低于多少时认输

4.如果使用zen6的zen.dll,需要设置参数 gtp4zen.exe -z 6
cgos遛狗建议参数:gtp4zen.exe -T 5 -i 100, 或者使用gtp4zen.lua脚本来控制时间
4.如果使用zen6的zen.dll,需要设置参数 gtp4zen.exe -z6,同时把dll重命名为zen6.dll
cgos遛狗建议参数:gtp4zen.exe -T5 -i100, 或者使用gtp4zen.lua脚本来控制时间


5.有bug请在qq群14501533提出


拥剑(qq80101277)
2017.11.27
此修改版作者:Breakwa11
程序原作者为 拥剑(qq80101277)
18 changes: 13 additions & 5 deletions gtp4zen/gtp4zen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ int _tmain(int argc, _TCHAR* argv[])
logprintf(L"每手最大思考时间(秒):%d", g_maxtime);
logprintf(L"每手最大模拟步数(步):%d", g_strength);

std::string zen_dll_path = GetModuleFilePath() + "zen.dll";
std::string zen_dll_path = GetModuleFilePath();
std::string lua_engine_path = GetModuleFilePath() + "gtp4zen.lua";
if (!boost::filesystem::is_regular_file(zen_dll_path.c_str())) {
fprintf(stderr, "ERROR: zen.dll not exist?\n");
Expand All @@ -222,13 +222,17 @@ int _tmain(int argc, _TCHAR* argv[])
if (6 == g_zenver) {
CZen6Gtp gtp6;
CGtp *pgtp = &gtp6;
if (pgtp->load(zen_dll_path.c_str(), lua_engine_path.c_str()))
if (pgtp->load((zen_dll_path + "zen6.dll").c_str(), lua_engine_path.c_str()))
_play_zen(pgtp);
else if (pgtp->load((zen_dll_path + "zen.dll").c_str(), lua_engine_path.c_str()))
_play_zen(pgtp);
pgtp->unload();
} else if (7 == g_zenver) {
CZen7Gtp gtp7;
CGtp *pgtp = &gtp7;
if (pgtp->load(zen_dll_path.c_str(), lua_engine_path.c_str()))
if (pgtp->load((zen_dll_path + "zen7.dll").c_str(), lua_engine_path.c_str()))
_play_zen(pgtp);
else if (pgtp->load((zen_dll_path + "zen.dll").c_str(), lua_engine_path.c_str()))
_play_zen(pgtp);
pgtp->unload();
}
Expand Down Expand Up @@ -285,11 +289,15 @@ static void _play_zen(CGtp *pgtp)
}
} else if ("place_free_handicap" == list[0] && list.size() >= 2) {
std::vector<std::string> posarray;
std::copy(list.begin() + 1, list.end(), posarray.begin());
for (auto it = list.begin() + 1; it != list.end(); ++it) {
posarray.push_back(*it);
}
result = pgtp->free_handicap(posarray);
} else if ("set_free_handicap" == list[0] && list.size() >= 2) {
std::vector<std::string> posarray;
std::copy(list.begin() + 1, list.end(), posarray.begin());
for (auto it = list.begin() + 1; it != list.end(); ++it) {
posarray.push_back(*it);
}
result = pgtp->free_handicap(posarray);
} else if ("winrate" == list[0]) {
result = pgtp->winrate();
Expand Down
8 changes: 7 additions & 1 deletion gtp4zen/zen6gtp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,14 @@ std::string CZen6Gtp::komi(float k)
std::string CZen6Gtp::free_handicap(const std::vector<std::string> &posarray)
{
logprintf(L"set_free_handicap()/place_free_handicap()");
bool first = true;
for (auto &item : posarray) {
if (!first)
{
play("w", "pass");
}
play("b", item.c_str());
first = false;
}
return "= \n";
}
Expand Down Expand Up @@ -468,7 +474,7 @@ std::string CZen6Gtp::__find_best_move(bool debug, int &x, int &y, int &simulati
fflush(stderr);
}
if (0 == i) {
if (strstr(S, "pass") == S) {
if (strstr(S, "pass") == S || simulation == 0) {
return "pass";
}

Expand Down
8 changes: 7 additions & 1 deletion gtp4zen/zen7gtp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,14 @@ std::string CZen7Gtp::komi(float k)
std::string CZen7Gtp::free_handicap(const std::vector<std::string> &posarray)
{
logprintf(L"set_free_handicap()/place_free_handicap()");
bool first = true;
for (auto &item : posarray) {
if (!first)
{
play("w", "pass");
}
play("b", item.c_str());
first = false;
}
return "= \n";
}
Expand Down Expand Up @@ -467,7 +473,7 @@ std::string CZen7Gtp::__find_best_move(bool debug, int &x, int &y, int &simulati
fflush(stderr);
}
if (0 == i) {
if (strstr(S, "pass") == S) {
if (strstr(S, "pass") == S || simulation == 0) {
return "pass";
}

Expand Down

0 comments on commit a979497

Please sign in to comment.