Skip to content

Commit

Permalink
初始版本
Browse files Browse the repository at this point in the history
  • Loading branch information
wjx0912 committed Jul 14, 2018
1 parent 5c8cc2d commit 7002e76
Show file tree
Hide file tree
Showing 86 changed files with 27,195 additions and 674 deletions.
22 changes: 22 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.vs
lib
obj

*.suo
*.obj
*.dll
*.exe
*.ilk
*.pdb
*.aps
*.iobj
*.ipdb
*.ipch
*.sdf
*.opensdf
*.tss
*.lib
*.exp

*.dpbcd
*.nlb
674 changes: 0 additions & 674 deletions LICENSE

This file was deleted.

5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
将zen6或者zen7转成命令行gtp。代码依赖boost(附boost props),开发环境vs2013update5。

使用了lua脚本可以自定义时间,代码写的很烂,没有版权,随便使用。

作者:拥剑:qq80101277
30 changes: 30 additions & 0 deletions bin/debug/gtp4zen.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
-- 如果不明白,可以删除这个文件!!!!!!删除后更好用:)
-- 有编程能力的应该容易理解

-- in: cur_move_num当前手数
-- in: time_left剩余时间
-- out: 当前手参考时间
-- 说明:当这个函数存在时命令行的-T参数自动失效,单位全部是毫秒
function genmove_calctime(cur_move_num, time_left)
if time_left > 240000 then -- 剩余时间在240秒以上
if cur_move_num < 50 then
return 15000
end
if cur_move_num < 100 then
return 12000
end
return 10000
elseif time_left > 120000 then -- 剩余时间在120-240秒之间
return 8000
elseif time_left > 60000 then -- 剩余时间在60-120秒之间
return 2000
else -- 剩余时间在60秒以内
return 500
end
end


-- 返回贴目,当这个函数存在时gtp的komi指令自动失效
function komi()
return 7.5
end
31 changes: 31 additions & 0 deletions bin/release/gtp4zen.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
-- 如果不明白,可以删除这个文件!!!!!!删除后更好用:)
-- 写过程序的应该容易理解

-- in: cur_move_num当前手数
-- in: time_left剩余时间
-- out: 当前手参考时间
-- 说明:当这个函数存在时命令行的-T参数自动失效,单位全部是毫秒
function genmove_calctime(cur_move_num, time_left)
if time_left > 240000 then -- 剩余时间在240秒以上
if cur_move_num < 50 then
return 15000
end
if cur_move_num < 100 then
return 12000
end
return 10000
elseif time_left > 120000 then -- 剩余时间在120-240秒之间
return 8000
elseif time_left > 60000 then -- 剩余时间在60-120秒之间
return 2000
else -- 剩余时间在60秒以内
return 500
end
end


-- 返回贴目,当这个函数存在时gtp的komi指令自动失效
-- 这个函数也可以删掉
function komi()
return 7.5
end
37 changes: 37 additions & 0 deletions bin/release/说明.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
1.把zen7的zen.dll拷贝到gtp4zen.exe所在的文件夹,运行即可,只需要gtp4zen.exe和zen.dll这2个文件
请参考gtp指令手册(http://www.lysator.liu.se/~gunnar/gtp/)或者使用sabaki等图形界面工具


2.gtp4zen.exe所在的文件夹如果存在gtp4zen.lua,命令行-T参数自动失效并使用gtp4zen.lua的时间控制,
这个脚本用于精细化时间控制,如果不明白用途可以★★删除★★gtp4zen.lua,默认★★文件存在并生效★★


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)
-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)
-i [ --ithink ] arg thinking interval, only set 100 when play cgos.
(default 1000ms)
-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)


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


5.有bug请在qq群14501533提出


拥剑(qq80101277)
2017.11.27
22 changes: 22 additions & 0 deletions gtp4zen.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.40629.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gtp4zen", "gtp4zen\gtp4zen.vcxproj", "{0F7ECD4F-B058-4E7C-8096-2F5BF4E5D677}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0F7ECD4F-B058-4E7C-8096-2F5BF4E5D677}.Debug|Win32.ActiveCfg = Debug|Win32
{0F7ECD4F-B058-4E7C-8096-2F5BF4E5D677}.Debug|Win32.Build.0 = Debug|Win32
{0F7ECD4F-B058-4E7C-8096-2F5BF4E5D677}.Release|Win32.ActiveCfg = Release|Win32
{0F7ECD4F-B058-4E7C-8096-2F5BF4E5D677}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
40 changes: 40 additions & 0 deletions gtp4zen/ReadMe.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
========================================================================
CONSOLE APPLICATION : gtp4zen Project Overview
========================================================================

AppWizard has created this gtp4zen application for you.

This file contains a summary of what you will find in each of the files that
make up your gtp4zen application.


gtp4zen.vcxproj
This is the main project file for VC++ projects generated using an Application Wizard.
It contains information about the version of Visual C++ that generated the file, and
information about the platforms, configurations, and project features selected with the
Application Wizard.

gtp4zen.vcxproj.filters
This is the filters file for VC++ projects generated using an Application Wizard.
It contains information about the association between the files in your project
and the filters. This association is used in the IDE to show grouping of files with
similar extensions under a specific node (for e.g. ".cpp" files are associated with the
"Source Files" filter).

gtp4zen.cpp
This is the main application source file.

/////////////////////////////////////////////////////////////////////////////
Other standard files:

StdAfx.h, StdAfx.cpp
These files are used to build a precompiled header (PCH) file
named gtp4zen.pch and a precompiled types file named StdAfx.obj.

/////////////////////////////////////////////////////////////////////////////
Other notes:

AppWizard uses "TODO:" comments to indicate parts of the source code you
should add to or customize.

/////////////////////////////////////////////////////////////////////////////
16 changes: 16 additions & 0 deletions gtp4zen/boost-static.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros">
<BOOST_DIR>D:\sdk\2013\boost_1_64_0\</BOOST_DIR>
</PropertyGroup>
<PropertyGroup>
<IncludePath>$(BOOST_DIR);$(IncludePath)</IncludePath>
<LibraryPath>$(BOOST_DIR)stage\lib\;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
</Project>
80 changes: 80 additions & 0 deletions gtp4zen/compile_time.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#ifndef __COMPILE_TIME_0354662121_H__
#define __COMPILE_TIME_0354662121_H__
#include <iostream>
#include <sstream>
#include <string>

// usage:
// cout << "Time_t when compiled: " << get_compiled_time() << endl;
// cout << "Time_t now: " << time(0) << endl;

inline bool get_compiled_tm(tm *_t)
{
std::string datestr = __DATE__;
std::string timestr = __TIME__;

std::istringstream iss_date(datestr);
std::string str_month;
int year;
int month;
int day;
iss_date >> str_month >> day >> year;

if (str_month == "Jan") month = 1;
else if (str_month == "Feb") month = 2;
else if (str_month == "Mar") month = 3;
else if (str_month == "Apr") month = 4;
else if (str_month == "May") month = 5;
else if (str_month == "Jun") month = 6;
else if (str_month == "Jul") month = 7;
else if (str_month == "Aug") month = 8;
else if (str_month == "Sep") month = 9;
else if (str_month == "Oct") month = 10;
else if (str_month == "Nov") month = 11;
else if (str_month == "Dec") month = 12;
// else exit(-1);

for (std::string::size_type pos = timestr.find(':'); pos != std::string::npos; pos = timestr.find(':', pos))
timestr[pos] = ' ';
std::istringstream iss_time(timestr);
int hour, min, sec;
iss_time >> hour >> min >> sec;

tm t = { 0 };
t.tm_mon = month - 1;
t.tm_mday = day;
t.tm_year = year - 1900;
t.tm_hour = hour;
t.tm_min = min;
t.tm_sec = sec;
memcpy(_t, &t, sizeof(tm));
return true;
}

inline time_t get_compiled_time()
{
tm _t;
get_compiled_tm(&_t);
return mktime(&_t);
}

inline std::string get_compile_strtime()
{
tm _t;
get_compiled_tm(&_t);

char buf[128] = "";
sprintf_s(buf
, "%d-%d-%d %d:%d:%d"
, _t.tm_year + 1900
, _t.tm_mon + 1
, _t.tm_mday
, _t.tm_hour
, _t.tm_min
, _t.tm_sec
);

return buf;
}

#endif
29 changes: 29 additions & 0 deletions gtp4zen/gtp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#ifndef __ZEN_GTP_H__
#define __ZEN_GTP_H__
#include <string>

class CGtp
{
public:
virtual bool load(std::string zen_dll_path, std::string lua_engine_path) = 0;
virtual bool unload() = 0;

public:
virtual std::string list_commands() = 0;
virtual std::string name() = 0;
virtual std::string version() = 0;
virtual std::string protocol_version() = 0;
virtual std::string clear_board() = 0;
virtual std::string boardsize(int size) = 0;
virtual std::string komi(float k) = 0;
virtual std::string free_handicap(const std::vector<std::string> &posarray) = 0;
virtual std::string winrate() = 0;
virtual std::string undo() = 0;
virtual std::string play(std::string color, std::string position) = 0;
virtual std::string genmove(std::string color) = 0;
virtual std::string time_settings(int main_time, int byo_yomi_time, int byo_yomi_stones) = 0;
virtual std::string time_left(std::string color, int time, int stones) = 0;
};

#endif

Loading

0 comments on commit 7002e76

Please sign in to comment.