From 8c88346c6bf4e2960a7f758c7c46e0f6129e7ff9 Mon Sep 17 00:00:00 2001
From: shangfengh <3495281661@qq.com>
Date: Sat, 29 Oct 2022 23:12:46 +0800
Subject: [PATCH] fix: resolve file collisions
---
CAPI/.gitignore | 499 +++
CAPI/API/API.vcxproj | 154 +
CAPI/API/API.vcxproj.filters | 17 +
CAPI/API/include/AI.h | 27 +
CAPI/API/include/API.h | 247 ++
CAPI/API/include/constants.h | 8 +
CAPI/API/include/logic.h | 112 +
CAPI/API/include/state.h | 27 +
CAPI/API/include/structures.h | 151 +
CAPI/API/src/AI.cpp | 15 +
CAPI/API/src/logic.cpp | 7 +
CAPI/CAPI.sln | 31 +
CAPI/CMakeLists.txt | 28 +
CAPI/README.md | 50 +
CAPI/proto/Message2Clients.grpc.pb.cc | 852 +++++
CAPI/proto/Message2Clients.grpc.pb.h | 3348 ++++++++++++++++++
CAPI/proto/Message2Clients.pb.cc | 4294 +++++++++++++++++++++++
CAPI/proto/Message2Clients.pb.h | 4327 ++++++++++++++++++++++++
CAPI/proto/Message2Server.grpc.pb.cc | 25 +
CAPI/proto/Message2Server.grpc.pb.h | 35 +
CAPI/proto/Message2Server.pb.cc | 2006 +++++++++++
CAPI/proto/Message2Server.pb.h | 1864 ++++++++++
CAPI/proto/MessageType.grpc.pb.cc | 25 +
CAPI/proto/MessageType.grpc.pb.h | 35 +
CAPI/proto/MessageType.pb.cc | 240 ++
CAPI/proto/MessageType.pb.h | 411 +++
dependency/.gitignore | 363 ++
dependency/Dockerfile/README.md | 4 +
dependency/README.md | 10 +
dependency/dll/README.md | 4 +
dependency/lib/README.md | 4 +
dependency/proto/.clang-format | 283 ++
dependency/proto/Message2Clients.proto | 125 +
dependency/proto/Message2Server.proto | 62 +
dependency/proto/MessageType.proto | 110 +
dependency/proto/README.md | 3 +
dependency/proto/cpp_output.sh | 10 +
dependency/proto/format.sh | 75 +
dependency/shell/README.md | 4 +
dependency/shell/format.sh | 21 +
resource/README.md | 3 +
resource/capi_uml.png | Bin 0 -> 10953 bytes
resource/capi_uml.vsdx | Bin 0 -> 25797 bytes
resource/structure.png | Bin 0 -> 66930 bytes
resource/structure.vsdx | Bin 0 -> 65739 bytes
45 files changed, 19916 insertions(+)
create mode 100644 CAPI/.gitignore
create mode 100644 CAPI/API/API.vcxproj
create mode 100644 CAPI/API/API.vcxproj.filters
create mode 100644 CAPI/API/include/AI.h
create mode 100644 CAPI/API/include/API.h
create mode 100644 CAPI/API/include/constants.h
create mode 100644 CAPI/API/include/logic.h
create mode 100644 CAPI/API/include/state.h
create mode 100644 CAPI/API/include/structures.h
create mode 100644 CAPI/API/src/AI.cpp
create mode 100644 CAPI/API/src/logic.cpp
create mode 100644 CAPI/CAPI.sln
create mode 100644 CAPI/CMakeLists.txt
create mode 100644 CAPI/README.md
create mode 100644 CAPI/proto/Message2Clients.grpc.pb.cc
create mode 100644 CAPI/proto/Message2Clients.grpc.pb.h
create mode 100644 CAPI/proto/Message2Clients.pb.cc
create mode 100644 CAPI/proto/Message2Clients.pb.h
create mode 100644 CAPI/proto/Message2Server.grpc.pb.cc
create mode 100644 CAPI/proto/Message2Server.grpc.pb.h
create mode 100644 CAPI/proto/Message2Server.pb.cc
create mode 100644 CAPI/proto/Message2Server.pb.h
create mode 100644 CAPI/proto/MessageType.grpc.pb.cc
create mode 100644 CAPI/proto/MessageType.grpc.pb.h
create mode 100644 CAPI/proto/MessageType.pb.cc
create mode 100644 CAPI/proto/MessageType.pb.h
create mode 100644 dependency/.gitignore
create mode 100644 dependency/Dockerfile/README.md
create mode 100644 dependency/README.md
create mode 100644 dependency/dll/README.md
create mode 100644 dependency/lib/README.md
create mode 100644 dependency/proto/.clang-format
create mode 100644 dependency/proto/Message2Clients.proto
create mode 100644 dependency/proto/Message2Server.proto
create mode 100644 dependency/proto/MessageType.proto
create mode 100644 dependency/proto/README.md
create mode 100644 dependency/proto/cpp_output.sh
create mode 100644 dependency/proto/format.sh
create mode 100644 dependency/shell/README.md
create mode 100644 dependency/shell/format.sh
create mode 100644 resource/README.md
create mode 100644 resource/capi_uml.png
create mode 100644 resource/capi_uml.vsdx
create mode 100644 resource/structure.png
create mode 100644 resource/structure.vsdx
diff --git a/CAPI/.gitignore b/CAPI/.gitignore
new file mode 100644
index 0000000..698ed27
--- /dev/null
+++ b/CAPI/.gitignore
@@ -0,0 +1,499 @@
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+##
+## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
+
+# User-specific files
+*.rsuser
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Mono auto generated files
+mono_crash.*
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+[Ww][Ii][Nn]32/
+[Aa][Rr][Mm]/
+[Aa][Rr][Mm]64/
+bld/
+[Bb]in/
+[Oo]bj/
+[Ll]og/
+[Ll]ogs/
+
+# Visual Studio 2015/2017 cache/options directory
+.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# Visual Studio 2017 auto generated files
+Generated\ Files/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+# NUnit
+*.VisualState.xml
+TestResult.xml
+nunit-*.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# Benchmark Results
+BenchmarkDotNet.Artifacts/
+
+# .NET Core
+project.lock.json
+project.fragment.lock.json
+artifacts/
+
+# ASP.NET Scaffolding
+ScaffoldingReadMe.txt
+
+# StyleCop
+StyleCopReport.xml
+
+# Files built by Visual Studio
+*_i.c
+*_p.c
+*_h.h
+*.ilk
+*.meta
+*.obj
+*.iobj
+*.pch
+*.pdb
+*.ipdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*_wpftmp.csproj
+*.log
+*.tlog
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opendb
+*.opensdf
+*.sdf
+*.cachefile
+*.VC.db
+*.VC.VC.opendb
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+*.sap
+
+# Visual Studio Trace Files
+*.e2e
+
+# TFS 2012 Local Workspace
+$tf/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# AxoCover is a Code Coverage Tool
+.axoCover/*
+!.axoCover/settings.json
+
+# Coverlet is a free, cross platform Code Coverage Tool
+coverage*.json
+coverage*.xml
+coverage*.info
+
+# Visual Studio code coverage results
+*.coverage
+*.coveragexml
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+# Note: Comment the next line if you want to checkin your web deploy settings,
+# but database connection strings (with potential passwords) will be unencrypted
+*.pubxml
+*.publishproj
+
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
+# checkin your Azure Web App publish settings, but sensitive information contained
+# in these scripts will be unencrypted
+PublishScripts/
+
+# NuGet Packages
+*.nupkg
+# NuGet Symbol Packages
+*.snupkg
+# The packages folder can be ignored because of Package Restore
+**/[Pp]ackages/*
+# except build/, which is used as an MSBuild target.
+!**/[Pp]ackages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/[Pp]ackages/repositories.config
+# NuGet v3's project.json files produces more ignorable files
+*.nuget.props
+*.nuget.targets
+
+# Microsoft Azure Build Output
+csx/
+*.build.csdef
+
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directories and files
+AppPackages/
+BundleArtifacts/
+Package.StoreAssociation.xml
+_pkginfo.txt
+*.appx
+*.appxbundle
+*.appxupload
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!?*.[Cc]ache/
+
+# Others
+ClientBin/
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.jfm
+*.pfx
+*.publishsettings
+orleans.codegen.cs
+
+# Including strong name files can present a security risk
+# (https://github.com/github/gitignore/pull/2483#issue-259490424)
+#*.snk
+
+# Since there are multiple workflows, uncomment next line to ignore bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+#bower_components/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+ServiceFabricBackup/
+*.rptproj.bak
+
+# SQL Server files
+*.mdf
+*.ldf
+*.ndf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+*.rptproj.rsuser
+*- [Bb]ackup.rdl
+*- [Bb]ackup ([0-9]).rdl
+*- [Bb]ackup ([0-9][0-9]).rdl
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+node_modules/
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
+*.vbw
+
+# Visual Studio 6 auto-generated project file (contains which files were open etc.)
+*.vbp
+
+# Visual Studio 6 workspace and project file (working project files containing files to include in project)
+*.dsw
+*.dsp
+
+# Visual Studio 6 technical files
+*.ncb
+*.aps
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# Paket dependency manager
+.paket/paket.exe
+paket-files/
+
+# FAKE - F# Make
+.fake/
+
+# CodeRush personal settings
+.cr/personal
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc
+
+# Cake - Uncomment if you are using it
+# tools/**
+# !tools/packages.config
+
+# Tabs Studio
+*.tss
+
+# Telerik's JustMock configuration file
+*.jmconfig
+
+# BizTalk build output
+*.btp.cs
+*.btm.cs
+*.odx.cs
+*.xsd.cs
+
+# OpenCover UI analysis results
+OpenCover/
+
+# Azure Stream Analytics local run output
+ASALocalRun/
+
+# MSBuild Binary and Structured Log
+*.binlog
+
+# NVidia Nsight GPU debugger configuration file
+*.nvuser
+
+# MFractors (Xamarin productivity tool) working folder
+.mfractor/
+
+# Local History for Visual Studio
+.localhistory/
+
+# Visual Studio History (VSHistory) files
+.vshistory/
+
+# BeatPulse healthcheck temp database
+healthchecksdb
+
+# Backup folder for Package Reference Convert tool in Visual Studio 2017
+MigrationBackup/
+
+# Ionide (cross platform F# VS Code tools) working folder
+.ionide/
+
+# Fody - auto-generated XML schema
+FodyWeavers.xsd
+
+# VS Code files for those working on multiple tools
+.vscode/*
+!.vscode/settings.json
+!.vscode/tasks.json
+!.vscode/launch.json
+!.vscode/extensions.json
+*.code-workspace
+
+# Local History for Visual Studio Code
+.history/
+
+# Windows Installer files from build outputs
+*.cab
+*.msi
+*.msix
+*.msm
+*.msp
+
+# JetBrains Rider
+*.sln.iml
+
+#THUAI playback file
+*.thuaipb
+
+# Prerequisites
+*.d
+
+# Compiled Object files
+*.slo
+*.lo
+*.o
+*.obj
+
+# Precompiled Headers
+*.gch
+*.pch
+
+# Compiled Dynamic libraries
+*.so
+*.dylib
+*.dll
+
+# Fortran module files
+*.mod
+*.smod
+
+# Compiled Static libraries
+*.lai
+*.la
+*.a
+*.lib
+
+# Executables
+*.exe
+*.out
+*.app
+
+# Prerequisites
+*.d
+
+# Object files
+*.o
+*.ko
+*.obj
+*.elf
+
+# Linker output
+*.ilk
+*.map
+*.exp
+
+# Precompiled Headers
+*.gch
+*.pch
+
+# Libraries
+*.lib
+*.a
+*.la
+*.lo
+
+# Shared objects (inc. Windows DLLs)
+*.dll
+*.so
+*.so.*
+*.dylib
+
+# Executables
+*.exe
+*.out
+*.app
+*.i*86
+*.x86_64
+*.hex
+
+# Debug files
+*.dSYM/
+*.su
+*.idb
+*.pdb
+
+# Kernel Module Compile Results
+*.mod*
+*.cmd
+.tmp_versions/
+modules.order
+Module.symvers
+Mkfile.old
+dkms.conf
+
+CMakeLists.txt.user
+CMakeCache.txt
+CMakeFiles
+CMakeScripts
+Testing
+Makefile
+cmake_install.cmake
+install_manifest.txt
+compile_commands.json
+CTestTestfile.cmake
+_deps
diff --git a/CAPI/API/API.vcxproj b/CAPI/API/API.vcxproj
new file mode 100644
index 0000000..33f7ab9
--- /dev/null
+++ b/CAPI/API/API.vcxproj
@@ -0,0 +1,154 @@
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+
+ 16.0
+ Win32Proj
+ {b9ac3133-177d-453c-8066-ed4702d3f36a}
+ API
+ 10.0
+
+
+
+ Application
+ true
+ v143
+ Unicode
+
+
+ Application
+ false
+ v143
+ true
+ Unicode
+
+
+ Application
+ true
+ v143
+ Unicode
+
+
+ Application
+ false
+ v143
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+ false
+
+
+ true
+
+
+ false
+
+
+
+ Level3
+ true
+ WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+ stdcpp17
+ stdc17
+
+
+ Console
+ true
+
+
+
+
+ Level3
+ true
+ true
+ true
+ WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+ stdcpp17
+ stdc17
+
+
+ Console
+ true
+ true
+ true
+
+
+
+
+ Level3
+ true
+ _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+ stdcpp17
+ stdc17
+
+
+ Console
+ true
+
+
+
+
+ Level3
+ true
+ true
+ true
+ NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+ stdcpp17
+ stdc17
+
+
+ Console
+ true
+ true
+ true
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CAPI/API/API.vcxproj.filters b/CAPI/API/API.vcxproj.filters
new file mode 100644
index 0000000..afef69e
--- /dev/null
+++ b/CAPI/API/API.vcxproj.filters
@@ -0,0 +1,17 @@
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
+
+
+
\ No newline at end of file
diff --git a/CAPI/API/include/AI.h b/CAPI/API/include/AI.h
new file mode 100644
index 0000000..d274d3d
--- /dev/null
+++ b/CAPI/API/include/AI.h
@@ -0,0 +1,27 @@
+#pragma once
+#ifndef AI_H
+#define AI_H
+
+#include "API.h"
+
+// 暂定版本:Human和Butcher全部继承AI类,
+class IAI
+{
+public:
+ IAI()
+ {
+ }
+ virtual void play(IAPI& api) = 0;
+};
+
+class AI : public IAI
+{
+public:
+ AI() :
+ IAI()
+ {
+ }
+ void play(IAPI& api) override;
+};
+
+#endif
\ No newline at end of file
diff --git a/CAPI/API/include/API.h b/CAPI/API/include/API.h
new file mode 100644
index 0000000..076bff2
--- /dev/null
+++ b/CAPI/API/include/API.h
@@ -0,0 +1,247 @@
+#pragma once
+#ifndef API_H
+#define API_H
+
+#ifdef _MSC_VER
+#pragma warning(disable : 4996)
+#endif
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "structures.h"
+
+const constexpr int num_of_grid_per_cell = 1000;
+
+class ILogic
+{
+ // API中依赖Logic的部分
+
+public:
+ // 获取服务器发来的所有消息,要注意线程安全问题
+ virtual protobuf::MessageToClient GetFullMessage() = 0;
+
+ // 供IAPI使用的操作相关的部分
+ virtual bool Move(protobuf::MoveMsg) = 0;
+ virtual bool PickProp(protobuf::PickMsg) = 0;
+ virtual bool UseProp(protobuf::IDMsg) = 0;
+ virtual bool UseSkill(protobuf::IDMsg) = 0;
+ virtual void SendMessage(protobuf::SendMsg) = 0;
+ virtual bool HaveMessage(protobuf::IDMsg) = 0;
+ virtual protobuf::MsgRes GetMessage(protobuf::IDMsg) = 0;
+
+ virtual bool Escape(protobuf::IDMsg) = 0;
+
+ // 说明:双向stream由三个函数共同实现,两个记录开始和结束,结果由Logic里的私有的成员变量记录,获得返回值则另调函数
+ virtual bool StartFixMachine(protobuf::IDMsg) = 0;
+ virtual bool EndFixMachine(protobuf::IDMsg) = 0;
+ virtual bool GetFixStatus() = 0;
+
+ virtual bool StartSaveHuman(protobuf::IDMsg) = 0;
+ virtual bool EndSaveHuman(protobuf::IDMsg) = 0;
+ virtual bool GetSaveStatus() = 0;
+
+ virtual bool Attack(protobuf::AttackMsg) = 0;
+ virtual bool CarryHuman(protobuf::IDMsg) = 0;
+ virtual bool ReleaseHuman(protobuf::IDMsg) = 0;
+ virtual bool HangHuman(protobuf::IDMsg) = 0;
+
+ virtual bool WaitThread() = 0;
+
+ virtual int GetCounter() = 0;
+};
+
+class IAPI
+{
+public:
+ // 选手可执行的操作,应当保证所有函数的返回值都应当为std::future,例如下面的移动函数:
+ // 指挥本角色进行移动,`timeInMilliseconds` 为移动时间,单位为毫秒;`angleInRadian` 表示移动的方向,单位是弧度,使用极坐标——竖直向下方向为 x 轴,水平向右方向为 y 轴
+ virtual std::future Move(uint32_t timeInMilliseconds, double angleInRadian) = 0;
+
+ // 向特定方向移动
+ virtual std::future MoveRight(uint32_t timeInMilliseconds) = 0;
+ virtual std::future MoveUp(uint32_t timeInMilliseconds) = 0;
+ virtual std::future MoveLeft(uint32_t timeInMilliseconds) = 0;
+ virtual std::future MoveDown(uint32_t timeInMilliseconds) = 0;
+
+ // 捡道具、使用技能
+ virtual std::future PickProp() = 0;
+ virtual std::future UseProp() = 0;
+ virtual std::future UseSkill() = 0;
+
+ // 发送信息、接受信息
+ virtual std::future SendMessage(int, std::string) = 0;
+ [[nodiscard]] virtual std::future HaveMessage() = 0;
+ [[nodiscard]] virtual std::future> GetMessage() = 0;
+
+ // 等待下一帧
+ virtual std::future Wait() = 0;
+
+ // 获取视野内可见的人类/屠夫的信息
+ [[nodiscard]] virtual std::vector> GetHuman() const = 0;
+ [[nodiscard]] virtual std::vector> GetButcher() const = 0;
+
+ // 获取视野内可见的道具信息
+ [[nodiscard]] virtual std::vector> GetProps() const = 0;
+
+ // 获取地图信息,视野外的地图统一为Land
+ [[nodiscard]] virtual std::array, 50> GetFullMap() const = 0;
+ [[nodiscard]] virtual THUAI6::PlaceType GetPlaceType(int32_t CellX, int32_t CellY) const = 0;
+
+ // 获取所有玩家的GUID
+ [[nodiscard]] virtual const std::vector GetPlayerGUIDs() const = 0;
+
+ // 获取游戏目前所进行的帧数
+ [[nodiscard]] virtual int GetFrameCount() const = 0;
+
+ /*****人类阵营的特定函数*****/
+
+ virtual std::future StartFixMachine() = 0;
+ virtual std::future EndFixMachine() = 0;
+ virtual std::future GetFixStatus() = 0;
+ virtual std::future StartSaveHuman() = 0;
+ virtual std::future EndSaveHuman() = 0;
+ virtual std::future GetSaveStatus() = 0;
+ virtual std::future Escape() = 0;
+ [[nodiscard]] virtual std::shared_ptr HumanGetSelfInfo() const = 0;
+
+ /*****屠夫阵营的特定函数*****/
+
+ virtual std::future Attack(double angleInRadian) = 0;
+ virtual std::future CarryHuman() = 0;
+ virtual std::future ReleaseHuman() = 0;
+ virtual std::future HangHuman() = 0;
+ [[nodiscard]] virtual std::shared_ptr ButcherGetSelfInfo() const = 0;
+
+ /*****选手可能用的辅助函数*****/
+
+ // 获取指定格子中心的坐标
+ [[nodiscard]] static inline int CellToGrid(int cell) noexcept
+ {
+ return cell * num_of_grid_per_cell + num_of_grid_per_cell / 2;
+ }
+
+ // 获取指定坐标点所位于的格子的 X 序号
+ [[nodiscard]] static inline int GridToCell(int grid) noexcept
+ {
+ return grid / num_of_grid_per_cell;
+ }
+
+ IAPI(ILogic& logic) :
+ logic(logic)
+ {
+ }
+
+ virtual ~IAPI()
+ {
+ }
+
+protected:
+ ILogic& logic;
+};
+
+// 给Logic使用的IAPI接口,为了保证面向对象的设计模式
+class IAPIForLogic : public IAPI
+{
+public:
+ IAPIForLogic(ILogic& logic) :
+ IAPI(logic)
+ {
+ }
+ virtual void StartTimer() = 0;
+ virtual void EndTimer() = 0;
+};
+
+class HumanAPI : public IAPIForLogic
+{
+public:
+ HumanAPI(ILogic& logic) :
+ IAPIForLogic(logic)
+ {
+ }
+};
+
+class ButcherAPI : public IAPIForLogic
+{
+public:
+ ButcherAPI(ILogic& logic) :
+ IAPIForLogic(logic)
+ {
+ }
+};
+
+// class IHumanAPI : public IAPIForLogic
+// {
+// public:
+// IHumanAPI(ILogic& logic) :
+// IAPIForLogic(logic)
+// {
+// }
+// virtual std::future StartFixMachine() = 0;
+// virtual std::future EndFixMachine() = 0;
+// virtual std::future GetFixStatus() = 0;
+// virtual std::future StartSaveHuman() = 0;
+// virtual std::future EndSaveHuman() = 0;
+// virtual std::future GetSaveStatus() = 0;
+// virtual std::future Escape() = 0;
+// [[nodiscard]] virtual std::shared_ptr GetSelfInfo() const = 0;
+// };
+
+// class IButcherAPI : public IAPIForLogic
+// {
+// public:
+// IButcherAPI(Logic& logic) :
+// IAPIForLogic(logic)
+// {
+// }
+// virtual std::future Attack(double angleInRadian) = 0;
+// virtual std::future CarryHuman() = 0;
+// virtual std::future ReleaseHuman() = 0;
+// virtual std::future HangHuman() = 0;
+// [[nodiscard]] virtual std::shared_ptr GetSelfInfo() const = 0;
+// };
+
+// class HumanAPI : public IHumanAPI
+// {
+// public:
+// HumanAPI(Logic& logic) :
+// IHumanAPI(logic)
+// {
+// }
+// };
+
+// class DebugHumanAPI : public IHumanAPI
+// {
+// public:
+// DebugHumanAPI(Logic& logic) :
+// IHumanAPI(logic)
+// {
+// }
+// };
+
+// class ButhcerAPI : public IButcherAPI
+// {
+// public:
+// ButhcerAPI(Logic& logic) :
+// IButcherAPI(logic)
+// {
+// }
+// };
+
+// class DebugButcherAPI : public IButcherAPI
+// {
+// public:
+// DebugButcherAPI(Logic& logic) :
+// IButcherAPI(logic)
+// {
+// }
+// };
+
+#endif
\ No newline at end of file
diff --git a/CAPI/API/include/constants.h b/CAPI/API/include/constants.h
new file mode 100644
index 0000000..735bd03
--- /dev/null
+++ b/CAPI/API/include/constants.h
@@ -0,0 +1,8 @@
+#pragma once
+#ifndef CONSTANTS_H
+#define CONSTANTS_H
+
+namespace Constants
+{
+}
+#endif
\ No newline at end of file
diff --git a/CAPI/API/include/logic.h b/CAPI/API/include/logic.h
new file mode 100644
index 0000000..6851596
--- /dev/null
+++ b/CAPI/API/include/logic.h
@@ -0,0 +1,112 @@
+#pragma once
+
+#ifndef LOGIC_H
+#define LOGIC_H
+
+#ifdef _MSC_VER
+#pragma warning(disable : 4996)
+#endif
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include "API.h"
+#include "AI.h"
+
+// 封装了通信组件和对AI对象进行操作
+class Logic : public ILogic
+{
+private:
+ // gRPC客户端的stub,所有与服务端之间的通信操作都需要基于stub完成。
+ std::unique_ptr THUAI6Stub;
+ // ID、阵营记录
+ int playerID;
+ THUAI6::PlayerType playerType;
+
+ // 类型记录
+ THUAI6::HumanType humanType;
+ THUAI6::ButcherType butcherType;
+
+ // GUID信息
+ std::vector playerGUIDs;
+
+ // THUAI5中的通信组件可以完全被我们的stub取代,故无须再写
+
+ std::unique_ptr pAI;
+
+ std::shared_ptr pAPI;
+
+ std::thread tAI;
+
+ mutable std::mutex mtxAI;
+ mutable std::mutex mtxState;
+ mutable std::mutex mtxBuffer;
+
+ std::condition_variable cvBuffer;
+ std::condition_variable cvAI;
+
+ // 信息队列目前可能会不用?具体待定
+
+ // 存储状态,分别是现在的状态和缓冲区的状态。
+ State state[2];
+ State* currentState;
+ State* bufferState;
+
+ // 是否应该执行player()
+ std::atomic_bool AILoop = true;
+
+ // buffer是否更新完毕
+ bool bufferUpdated = true;
+
+ // 是否可以启用当前状态
+ bool currentStateAccessed = false;
+
+ // 是否应当启动AI
+ bool AIStart = false;
+
+ // 控制内容更新的变量
+ std::atomic_bool freshed = false;
+
+ // 所有API中声明的函数都需要在此处重写,先暂时略过,等到之后具体实现时再考虑
+
+ // 执行AI线程
+ void PlayerWrapper(std::function player);
+
+ // THUAI5中的一系列用于处理信息的函数可能也不会再用
+
+ // 将信息加载到buffer
+ void LoadBuffer(std::shared_ptr);
+
+ // 解锁状态更新线程
+ void UnBlockBuffer();
+
+ // 解锁AI线程
+ void UnBlockAI();
+
+ // 更新状态
+ void Update() noexcept;
+
+ // 等待
+ void Wait() noexcept;
+
+public:
+ // 构造函数还需要传更多参数,有待补充
+ Logic(std::shared_ptr channel);
+
+ ~Logic() = default;
+
+ // Main函数同上
+ void Main();
+};
+
+#endif
\ No newline at end of file
diff --git a/CAPI/API/include/state.h b/CAPI/API/include/state.h
new file mode 100644
index 0000000..f699d24
--- /dev/null
+++ b/CAPI/API/include/state.h
@@ -0,0 +1,27 @@
+#pragma once
+#ifndef STATE_H
+#define STATE_H
+
+#include
+
+#include "structures.h"
+
+// 存储场上的状态
+struct State
+{
+ uint32_t teamScore;
+
+ // 自身信息,根据playerType的不同,可以调用的值也不同。
+ std::shared_ptr humanSelf;
+ std::shared_ptr butcherSelf;
+
+ std::vector> humans;
+ std::vector> butchers;
+ std::vector> props;
+
+ THUAI6::PlaceType gamemap[51][51];
+
+ std::vector guids;
+};
+
+#endif
\ No newline at end of file
diff --git a/CAPI/API/include/structures.h b/CAPI/API/include/structures.h
new file mode 100644
index 0000000..06dd24c
--- /dev/null
+++ b/CAPI/API/include/structures.h
@@ -0,0 +1,151 @@
+#pragma once
+#ifndef STRUCTURES_H
+#define STRUCTURES_H
+
+#include
+#include
+#include