Browse Source

Merge pull request #527 from DragonAura/dev

fix(CAPI): 🐛 fix wrong get message
tags/v0.1.0
shangfengh GitHub 2 years ago
parent
commit
ef6d7b798d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 95 additions and 90 deletions
  1. +2
    -2
      CAPI/cpp/API/src/logic.cpp
  2. +47
    -44
      docs/CAPI接口(cpp).md
  3. +46
    -44
      docs/CAPI接口(python).md

+ 2
- 2
CAPI/cpp/API/src/logic.cpp View File

@@ -583,12 +583,12 @@ void Logic::LoadBufferCase(const protobuf::MessageOfObj& item)
{ {
if (Proto2THUAI6::newsTypeDict[news.news_case()] == THUAI6::NewsType::TextMessage) if (Proto2THUAI6::newsTypeDict[news.news_case()] == THUAI6::NewsType::TextMessage)
{ {
messageQueue.emplace(std::make_pair(news.to_id(), news.text_message()));
messageQueue.emplace(std::make_pair(news.from_id(), news.text_message()));
logger->debug("Add News!"); logger->debug("Add News!");
} }
else if (Proto2THUAI6::newsTypeDict[news.news_case()] == THUAI6::NewsType::BinaryMessage) else if (Proto2THUAI6::newsTypeDict[news.news_case()] == THUAI6::NewsType::BinaryMessage)
{ {
messageQueue.emplace(std::make_pair(news.to_id(), news.binary_message()));
messageQueue.emplace(std::make_pair(news.from_id(), news.binary_message()));
logger->debug("Add Binary News!"); logger->debug("Add Binary News!");
} }
else else


+ 47
- 44
docs/CAPI接口(cpp).md View File

@@ -5,83 +5,85 @@


### 主动指令 ### 主动指令
- 每帧最多发送50条主动指令 - 每帧最多发送50条主动指令
- EndAllAction() 及 Move 指令调用数总和一帧内不超过 10 次
- EndAllAction 及 Move 指令调用数总和一帧内不超过 10 次


#### 移动 #### 移动
- `std::future<bool> Move(int64_t timeInMilliseconds, double angleInRadian)`:移动,`timeInMilliseconds` 为移动时间,单位毫秒;`angleInRadian` 表示移动方向,单位弧度,使用极坐标,**竖直向下方向为x轴,水平向右方向为y轴**。因为移动过程中你会受到多种干扰使得移动结果不符合你的预期;因此建议小步移动,边移动边考虑之后的行为。
- `std::future<bool> MoveRight(uint32_t timeInMilliseconds)`即向右移动,`MoveLeft`、`MoveDown`、`MoveUp`同理
- `std::future<bool> Move(int64_t timeInMilliseconds, double angleInRadian)`移动,`timeInMilliseconds` 为移动时间,单位毫秒;`angleInRadian` 表示移动方向,单位弧度,使用极坐标,**竖直向下方向为 x 轴,水平向右方向为 y 轴**。因为移动过程中你会受到多种干扰使得移动结果不符合你的预期;因此建议小步移动,边移动边考虑之后的行为。
- `std::future<bool> MoveRight(uint32_t timeInMilliseconds)`即向右移动,`MoveLeft`、`MoveDown`、`MoveUp` 同理


#### 使用技能 #### 使用技能
- `std::future<bool> UseSkill(int32_t skillID)`:使用对应序号的主动技能
- `std::future<bool> UseSkill(int32_t skillID)`使用对应序号的主动技能


#### 人物 #### 人物
- `std::future<bool> EndAllAction()`:可以使不处在不可行动状态中的玩家终止当前行动
- 在指令仍在进行时,重复发出同一类型的交互指令和移动指令是无效的,你需要先发出 Stop 指令终止进行的指令
- EndAllAction() 及 Move 指令调用数总和一帧内不超过 10 次
- `std::future<bool> EndAllAction()`可以使不处在不可行动状态中的玩家终止当前行动
- 在指令仍在进行时,重复发出同一类型的交互指令和移动指令是无效的,你需要先发出 EndAllAction 指令终止进行的指令
- 实际上唤醒或勉励不同的人是有效的


#### 攻击 #### 攻击
- `std::future<bool> Attack(double angleInRadian)`:`angleInRadian`为攻击方向
- `std::future<bool> Attack(double angleInRadian)`:`angleInRadian` 为攻击方向


#### 学习与毕业 #### 学习与毕业
- `std::future<bool> StartLearning()`:在教室里开始做作业
- `std::future<bool> StartOpenGate()`:开始开启校门
- `std::future<bool> Graduate()`:从开启的校门或隐藏校门毕业。
- `std::future<bool> StartLearning()`在教室里开始做作业
- `std::future<bool> StartOpenGate()`开始开启校门
- `std::future<bool> Graduate()`从开启的校门或隐藏校门毕业。


#### 勉励与唤醒 #### 勉励与唤醒
- `std::future<bool> StartEncourageMate(int64_t mateID)`:勉励对应玩家ID的学生。
- `std::future<bool> StartRouseMate(int64_t mateID)`:唤醒对应玩家ID的沉迷的学生。
- `std::future<bool> StartEncourageMate(int64_t mateID)`:勉励对应玩家 ID 的学生。
- `std::future<bool> StartRouseMate(int64_t mateID)`:唤醒对应玩家 ID 的沉迷的学生。


#### 地图互动 #### 地图互动
- `std::future<bool> OpenDoor()`:开门
- `std::future<bool> CloseDoor()`:关门
- `std::future<bool> SkipWindow()`:翻窗
- `std::future<bool> StartOpenChest()`:开箱
- `std::future<bool> OpenDoor()`开门
- `std::future<bool> CloseDoor()`关门
- `std::future<bool> SkipWindow()`翻窗
- `std::future<bool> StartOpenChest()`开箱


#### 道具 #### 道具
- `bool PickProp(THUAI6::PropType prop)`捡起与自己处于同一个格子(cell)的道具。
- `bool UseProp(THUAI6::PropType prop)`使用对应类型的道具
- `bool ThrowProp(THUAI6::PropType prop)`将对应类型的道具扔在原地
- `bool PickProp(THUAI6::PropType prop)`捡起与自己处于同一个格子(cell)的道具。
- `bool UseProp(THUAI6::PropType prop)`使用对应类型的道具
- `bool ThrowProp(THUAI6::PropType prop)`将对应类型的道具扔在原地


### 信息获取 ### 信息获取


#### 队内信息 #### 队内信息
- `std::future<bool> SendMessage(int64_t, std::string)`:给同队的队友发送消息,队友在下一帧收到。第一个参数指定发送的对象,第二个参数指定发送的内容,不得超过256字节。
- `bool HaveMessage()`:是否有队友发来的尚未接收的信息。
- `std::pair<int64_t, std::string> GetMessage()`:按照消息发送顺序获取来自队友的信息,第一个参数为发送该消息的PlayerID。
- `std::future<bool> SendTextMessage(int64_t, std::string)`:给同队的队友发送文本消息,队友在下一帧收到。第一个参数指定发送的对象,第二个参数指定发送的内容,形式为 Unicode 字符串,不得超过 256 字节。
- `std::future<bool> SendBinaryMessage(int64_t, std::string)`:给同队的队友发送二进制消息,队友在下一帧收到。第一个参数指定发送的对象,第二个参数指定发送的内容,形式为二进制字符串,不得超过 256 字节。
- `bool HaveMessage()`:是否有队友发来的尚未接收的信息。
- `std::pair<int64_t, std::string> GetMessage()`:按照消息发送顺序获取来自队友的信息,第一个参数为发送该消息的 PlayerID。
> 需要注意,收到的二进制消息和文本消息都会被这个函数一并返回,选手需要自行约定消息类型。


#### 查询可视范围内的信息 #### 查询可视范围内的信息
- `std::vector<std::shared_ptr<const THUAI6::Student>> GetStudents() const` :对于学生,返回所有学生的信息;对于捣蛋鬼,返回可视学生的信息。
- `std::vector<std::shared_ptr<const THUAI6::Tricker>> GetTrickers() const` :返回所有可视捣蛋鬼的信息。
- `std::vector<std::shared_ptr<const THUAI6::Prop>> GetProps() const` :返回所有可视道具的信息。
- `std::vector<std::shared_ptr<const THUAI6::Bullet>> GetBullets() const` :返回所有可视子弹(攻击)的信息。
- `std::vector<std::shared_ptr<const THUAI6::Student>> GetStudents() const`:对于学生,返回所有学生的信息;对于捣蛋鬼,返回可视学生的信息。
- `std::vector<std::shared_ptr<const THUAI6::Tricker>> GetTrickers() const`:返回所有可视捣蛋鬼的信息。
- `std::vector<std::shared_ptr<const THUAI6::Prop>> GetProps() const`:返回所有可视道具的信息。
- `std::vector<std::shared_ptr<const THUAI6::Bullet>> GetBullets() const`:返回所有可视子弹(攻击)的信息。
- `bool HaveView(int gridX, int gridY) const`:判断坐标是否可见 - `bool HaveView(int gridX, int gridY) const`:判断坐标是否可见


#### 查询特定位置物体的信息 #### 查询特定位置物体的信息


下面的 CellX 和 CellY 指的是地图格数,而非绝对坐标。 下面的 CellX 和 CellY 指的是地图格数,而非绝对坐标。


- `THUAI6::PlaceType GetPlaceType(int32_t cellX, int32_t cellY)` :返回某一位置场地种类信息。场地种类详见 structure.h
- `THUAI6::PlaceType GetPlaceType(int32_t cellX, int32_t cellY)`:返回某一位置场地种类信息。场地种类详见 structure.h。
- 以下指令,若查询物品当前在视野内,则返回最新进度/状态;若物品当前不在视野内、但曾经出现在视野内,则返回最后一次看到时的进度/状态;若物品从未出现在视野内,或查询位置没有对应的物品,则返回 -1。 - 以下指令,若查询物品当前在视野内,则返回最新进度/状态;若物品当前不在视野内、但曾经出现在视野内,则返回最后一次看到时的进度/状态;若物品从未出现在视野内,或查询位置没有对应的物品,则返回 -1。
- `int32_t GetChestProgress(int32_t cellX, int32_t cellY) const`:查询特定位置箱子开启进度
- `int32_t GetGateProgress(int32_t cellX, int32_t cellY) const`:查询特定位置校门开启进度
- `int32_t GetClassroomProgress(int32_t cellX, int32_t cellY) const`:查询特定位置教室作业完成进度
- `int32_t GetDoorProgress(int32_t cellX, int32_t cellY) const`:查询特定位置门开启状态
- `bool IsDoorOpen(int32_t cellX, int32_t cellY) const`:查询特定位置门是否开启,没有门/不在视野内也返回false
- `THUAI6::HiddenGateState GetHiddenGateState(int32_t cellX, int32_t cellY) const`::查询特定位置隐藏校门状态,没有隐藏校门/不在视野内返回THUAI6::HiddenGateState::Null
- `int32_t GetChestProgress(int32_t cellX, int32_t cellY) const`查询特定位置箱子开启进度
- `int32_t GetGateProgress(int32_t cellX, int32_t cellY) const`查询特定位置校门开启进度
- `int32_t GetClassroomProgress(int32_t cellX, int32_t cellY) const`查询特定位置教室作业完成进度
- `int32_t GetDoorProgress(int32_t cellX, int32_t cellY) const`查询特定位置门开启状态
- `bool IsDoorOpen(int32_t cellX, int32_t cellY) const`查询特定位置门是否开启,没有门/不在视野内也返回 false
- `THUAI6::HiddenGateState GetHiddenGateState(int32_t cellX, int32_t cellY) const`:查询特定位置隐藏校门状态,没有隐藏校门/不在视野内返回 THUAI6::HiddenGateState::Null


#### 其他 #### 其他
- `std::shared_ptr<const THUAI6::GameInfo> GetGameInfo() const`:查询当前游戏状态
- `std::vector<int64_t> GetPlayerGUIDs() const`:获取所有玩家的GUID
- `int GetFrameCount() const`:获取目前所进行的帧数
- `std::shared_ptr<const THUAI6::Tricker> GetSelfInfo() const`或`std::shared_ptr<const THUAI6::Student> GetSelfInfo() const`:获取自己的信息
- `std::vector<std::vector<THUAI6::PlaceType>> GetFullMap() const`:返回整张地图的地形信息。可以写成类似`api.GetFullMap()[x][y]`,其中x为地图自上到下第几行,y为自左向右第几列,注意从0开始
- `std::shared_ptr<const THUAI6::GameInfo> GetGameInfo() const`查询当前游戏状态
- `std::vector<int64_t> GetPlayerGUIDs() const`:获取所有玩家的 GUID
- `int GetFrameCount() const`获取目前所进行的帧数
- `std::shared_ptr<const THUAI6::Tricker> GetSelfInfo() const` `std::shared_ptr<const THUAI6::Student> GetSelfInfo() const`:获取自己的信息
- `std::vector<std::vector<THUAI6::PlaceType>> GetFullMap() const`:返回整张地图的地形信息。可以写成类似 `api.GetFullMap()[x][y]`,其中 x 为地图自上到下第几行,y 为自左向右第几列,注意从 0 开始


### 辅助函数 ### 辅助函数
`static inline int CellToGrid(int cell) noexcept`:将地图格数 cell 转换为绝对坐标 grid。
`static inline int CellToGrid(int cell) noexcept`将地图格数 cell 转换为绝对坐标 grid。


`static inline int GridToCell(int grid) noexcept`:将绝对坐标 grid 转换为地图格数 cell。
`static inline int GridToCell(int grid) noexcept`将绝对坐标 grid 转换为地图格数 cell。


下面为用于DEBUG的输出函数,选手仅在开启Debug模式的情况下可以使用
下面为用于 DEBUG 的输出函数,选手仅在开启 Debug 模式的情况下可以使用
~~~c++ ~~~c++
void Print(std::string str) const; void Print(std::string str) const;
void PrintStudent() const; void PrintStudent() const;
@@ -95,7 +97,7 @@
struct Player struct Player
{ {
std::vector<PropType> props;//大小固定为3,空的位置为NullPropType std::vector<PropType> props;//大小固定为3,空的位置为NullPropType
}
};
~~~ ~~~


## 接口一览 ## 接口一览
@@ -123,7 +125,8 @@
virtual std::future<bool> EndAllAction() = 0; virtual std::future<bool> EndAllAction() = 0;


// 发送信息、接受信息,注意收消息时无消息则返回nullopt // 发送信息、接受信息,注意收消息时无消息则返回nullopt
virtual std::future<bool> SendMessage(int64_t, std::string) = 0;
virtual std::future<bool> SendTextMessage(int64_t, std::string) = 0;
virtual std::future<bool> SendBinaryMessage(int64_t, std::string) = 0;
[[nodiscard]] virtual bool HaveMessage() = 0; [[nodiscard]] virtual bool HaveMessage() = 0;
[[nodiscard]] virtual std::pair<int64_t, std::string> GetMessage() = 0; [[nodiscard]] virtual std::pair<int64_t, std::string> GetMessage() = 0;




+ 46
- 44
docs/CAPI接口(python).md View File

@@ -5,97 +5,99 @@
## 接口解释 ## 接口解释


### 主动指令 ### 主动指令
- 每帧最多发送50条主动指令
- EndAllAction() 及 Move 指令调用数总和一帧内不超过 10 次
- 每帧最多发送 50 条主动指令
- EndAllAction 及 Move 指令调用数总和一帧内不超过 10 次


#### 移动 #### 移动


- `def Move(self, timeInMilliseconds: int, angle: float) -> Future[bool]`:移动,`timeInMilliseconds` 为移动时间,单位毫秒;`angleInRadian` 表示移动方向,单位弧度,使用极坐标,**竖直向下方向为 x 轴,水平向右方向为 y 轴**因为移动过程中你会受到多种干扰使得移动结果不符合你的预期;因此建议小步移动,边移动边考虑之后的行为。
- 5ms以内的移动指令会被禁止,你不应当使用过小的移动指令
- `def MoveRight(self, timeInMilliseconds: int) -> Future[bool]`即向右移动,`MoveLeft`、`MoveDown`、`MoveUp`同理
- `def Move(self, timeInMilliseconds: int, angle: float) -> Future[bool]`移动,`timeInMilliseconds` 为移动时间,单位毫秒;`angleInRadian` 表示移动方向,单位弧度,使用极坐标,**竖直向下方向为 x 轴,水平向右方向为 y 轴**因为移动过程中你会受到多种干扰使得移动结果不符合你的预期;因此建议小步移动,边移动边考虑之后的行为。
- 5ms 以内的移动指令会被禁止,你不应当使用过小的移动指令
- `def MoveRight(self, timeInMilliseconds: int) -> Future[bool]` 即向右移动, `MoveLeft`、`MoveDown`、`MoveUp` 同理


#### 使用技能 #### 使用技能


- `def UseSkill(self, skillID: int) -> Future[bool]`:使用对应序号的主动技能
- `def UseSkill(self, skillID: int) -> Future[bool]`使用对应序号的主动技能


#### 人物 #### 人物


- `def EndAllAction(self) -> Future[bool]`:可以使不处在不可行动状态中的玩家终止当前行动
- 在指令仍在进行时,重复发出同一类型的交互指令和移动指令是无效的,你需要先发出 Stop 指令终止进行的指令
- EndAllAction() 及 Move 指令调用数总和一帧内不超过 10 次
- `def EndAllAction(self) -> Future[bool]`:可以使不处在不可行动状态中的玩家终止当前行动
- 在指令仍在进行时,重复发出同一类型的交互指令和移动指令是无效的,你需要先发出 EndAllAction 指令终止进行的指令
- 实际上唤醒或勉励不同的人是有效的
- EndAllAction 及 Move 指令调用数总和一帧内不超过 10 次


#### 攻击 #### 攻击


- `def Attack(self, angle: float) -> Future[bool]`:`angleInRadian`为攻击方向
- `def Attack(self, angle: float) -> Future[bool]`:`angleInRadian` 为攻击方向


#### 学习与毕业 #### 学习与毕业


- `def StartLearning(self) -> Future[bool]`:在教室里开始做作业
- `def StartOpenGate(self) -> Future[bool]`:开始开启校门
- `def Graduate(self) -> Future[bool]`:从开启的校门或隐藏校门毕业。
- `def StartLearning(self) -> Future[bool]`在教室里开始做作业
- `def StartOpenGate(self) -> Future[bool]`开始开启校门
- `def Graduate(self) -> Future[bool]`从开启的校门或隐藏校门毕业。


#### 勉励与唤醒 #### 勉励与唤醒


- `def StartEncourageMate(self, mateID: int) -> Future[bool]`:勉励对应玩家 ID 的学生。
- `def StartEncourageMate(self, mateID: int) -> Future[bool]`勉励对应玩家 ID 的学生。
- `def StartRouseMate(self, mateID: int) -> Future[bool]`:唤醒对应玩家 ID 的沉迷的学生。 - `def StartRouseMate(self, mateID: int) -> Future[bool]`:唤醒对应玩家 ID 的沉迷的学生。


#### 地图互动 #### 地图互动


- `def OpenDoor(self) -> Future[bool]`:开门
- `def CloseDoor(self) -> Future[bool]`:关门
- `def SkipWindow(self) -> Future[bool]`:翻窗
- `def StartOpenChest(self) -> Future[bool]`:开箱
- `def OpenDoor(self) -> Future[bool]`开门
- `def CloseDoor(self) -> Future[bool]`关门
- `def SkipWindow(self) -> Future[bool]`翻窗
- `def StartOpenChest(self) -> Future[bool]`开箱


#### 道具 #### 道具


- `def PickProp(self, propType: THUAI6.PropType) -> Future[bool]`捡起与自己处于同一个格子(cell)的道具。
- `def UseProp(self, propType: THUAI6.PropType) -> Future[bool]`使用对应类型的道具
- `def ThrowProp(self, propType: THUAI6.PropType) -> Future[bool]`将对应类型的道具扔在原地
- `def PickProp(self, propType: THUAI6.PropType) -> Future[bool]`捡起与自己处于同一个格子(cell)的道具。
- `def UseProp(self, propType: THUAI6.PropType) -> Future[bool]`使用对应类型的道具
- `def ThrowProp(self, propType: THUAI6.PropType) -> Future[bool]`将对应类型的道具扔在原地


### 信息获取 ### 信息获取


#### 队内信息 #### 队内信息


- `def GetMessage(self) -> Tuple[int, str]`:给同队的队友发送消息,队友在下一帧收到。第一个参数指定发送的对象,第二个参数指定发送的内容,不得超过256字节。
- `def HaveMessage(self) -> bool`:是否有队友发来的尚未接收的信息。
- `def GetMessage(self) -> Tuple[int, str]`:按照消息发送顺序获取来自队友的信息,第一个参数为发送该消息的PlayerID。
- `def SendMessage(self, toID: int, message: Union[str, bytes]) -> Future[bool]`:给同队的队友发送消息,队友在下一帧收到。第一个参数指定发送的对象,第二个参数指定发送的内容,可以是Unicode字符串,也可以是二进制字符串;不得超过 256 字节。
- `def HaveMessage(self) -> bool`:是否有队友发来的尚未接收的信息。
- `def GetMessage(self) -> Tuple[int, Union[str, bytes]]`:按照消息发送顺序获取来自队友的信息,第一个参数为发送该消息的 PlayerID。
> 需要注意,文本消息和二进制消息都会在这里接受,选手可以简单地使用 `isinstance()` 来判断消息类型。


#### 查询可视范围内的信息 #### 查询可视范围内的信息


- `def GetStudents(self) -> List[THUAI6.Student]` :对于学生,返回所有学生的信息;对于捣蛋鬼,返回可视学生的信息。
- `def GetTrickers(self) -> List[THUAI6.Tricker]` :返回所有可视捣蛋鬼的信息。
- `def GetProps(self) -> List[THUAI6.Prop]` :返回所有可视道具的信息。
- `def GetBullets(self) -> List[THUAI6.Bullet]` :返回所有可视子弹(攻击)的信息。
- `def GetStudents(self) -> List[THUAI6.Student]`:对于学生,返回所有学生的信息;对于捣蛋鬼,返回可视学生的信息。
- `def GetTrickers(self) -> List[THUAI6.Tricker]`:返回所有可视捣蛋鬼的信息。
- `def GetProps(self) -> List[THUAI6.Prop]`:返回所有可视道具的信息。
- `def GetBullets(self) -> List[THUAI6.Bullet]`:返回所有可视子弹(攻击)的信息。
- `def HaveView(self, gridX: int, gridY: int) -> bool`:判断坐标是否可见 - `def HaveView(self, gridX: int, gridY: int) -> bool`:判断坐标是否可见


#### 查询特定位置物体的信息 #### 查询特定位置物体的信息


下面的 CellX 和 CellY 指的是地图格数,而非绝对坐标。 下面的 CellX 和 CellY 指的是地图格数,而非绝对坐标。


- `def GetPlaceType(self, cellX: int, cellY: int) -> THUAI6.PlaceType` :返回某一位置场地种类信息。场地种类详见 structure.h
- `def GetPlaceType(self, cellX: int, cellY: int) -> THUAI6.PlaceType`:返回某一位置场地种类信息。场地种类详见 structure.h。
- 以下指令,若查询物品当前在视野内,则返回最新进度/状态;若物品当前不在视野内、但曾经出现在视野内,则返回最后一次看到时的进度/状态;若物品从未出现在视野内,或查询位置没有对应的物品,则返回 -1。 - 以下指令,若查询物品当前在视野内,则返回最新进度/状态;若物品当前不在视野内、但曾经出现在视野内,则返回最后一次看到时的进度/状态;若物品从未出现在视野内,或查询位置没有对应的物品,则返回 -1。
- `def GetChestProgress(self, cellX: int, cellY: int) -> int`:查询特定位置箱子开启进度
- `def GetGateProgress(self, cellX: int, cellY: int) -> int`:查询特定位置校门开启进度
- `def GetClassroomProgress(self, cellX: int, cellY: int) -> int`:查询特定位置教室作业完成进度
- `def GetDoorProgress(self, cellX: int, cellY: int) -> int`:查询特定位置门开启状态
- `def IsDoorOpen(self, cellX: int, cellY: int) -> bool`:查询特定位置门是否开启,没有门/不在视野内也返回false
- `def GetHiddenGateState(self, cellX: int, cellY: int) -> THUAI6.HiddenGateState`::查询特定位置隐藏校门状态,没有隐藏校门/不在视野内返回THUAI6::HiddenGateState::Null
- `def GetChestProgress(self, cellX: int, cellY: int) -> int`查询特定位置箱子开启进度
- `def GetGateProgress(self, cellX: int, cellY: int) -> int`查询特定位置校门开启进度
- `def GetClassroomProgress(self, cellX: int, cellY: int) -> int`查询特定位置教室作业完成进度
- `def GetDoorProgress(self, cellX: int, cellY: int) -> int`查询特定位置门开启状态
- `def IsDoorOpen(self, cellX: int, cellY: int) -> bool`查询特定位置门是否开启,没有门/不在视野内也返回 false
- `def GetHiddenGateState(self, cellX: int, cellY: int) -> THUAI6.HiddenGateState`:查询特定位置隐藏校门状态,没有隐藏校门/不在视野内返回 THUAI6::HiddenGateState::Null


#### 其他 #### 其他


- `def GetGameInfo(self) -> THUAI6.GameInfo`:查询当前游戏状态
- `def GetPlayerGUIDs(self) -> List[int]`:获取所有玩家的GUID
- `def GetFrameCount(self) -> int`:获取目前所进行的帧数
- `def GetGameInfo(self) -> THUAI6.GameInfo`查询当前游戏状态
- `def GetPlayerGUIDs(self) -> List[int]`:获取所有玩家的 GUID
- `def GetFrameCount(self) -> int`获取目前所进行的帧数
- `def GetSelfInfo(self) -> Union[THUAI6.Student, THUAI6.Tricker]`:获取自己的信息 - `def GetSelfInfo(self) -> Union[THUAI6.Student, THUAI6.Tricker]`:获取自己的信息
- `def GetFullMap(self) -> List[List[THUAI6.PlaceType]]`:返回整张地图的地形信息。可以写成类似`self.GetFullMap()[x][y]`,其中x为地图自上到下第几行,y为自左向右第几列,注意从0开始
- `def GetFullMap(self) -> List[List[THUAI6.PlaceType]]`:返回整张地图的地形信息。可以写成类似 `self.GetFullMap()[x][y]`,其中 x 为地图自上到下第几行,y 为自左向右第几列,注意从 0 开始


### 辅助函数 ### 辅助函数


`def CellToGrid(cell: int) -> int`:将地图格数 cell 转换为绝对坐标 grid。
`def CellToGrid(cell: int) -> int`将地图格数 cell 转换为绝对坐标 grid。


`def GridToCell(grid: int) -> int`:将绝对坐标 grid 转换为地图格数 cell。
`def GridToCell(grid: int) -> int`将绝对坐标 grid 转换为地图格数 cell。


下面为用于DEBUG的输出函数,选手仅在开启 Debug 模式的情况下可以使用
下面为用于 DEBUG 的输出函数,选手仅在开启 Debug 模式的情况下可以使用


~~~python ~~~python
def Print(self, cont: str) -> None: def Print(self, cont: str) -> None:
@@ -191,7 +193,7 @@ class IAPI(metaclass=ABCMeta):
# 消息相关,接收消息时无消息则返回(-1, '') # 消息相关,接收消息时无消息则返回(-1, '')


@abstractmethod @abstractmethod
def SendMessage(self, toID: int, message: str) -> Future[bool]:
def SendMessage(self, toID: int, message: Union[str, bytes]) -> Future[bool]:
pass pass


@abstractmethod @abstractmethod
@@ -199,7 +201,7 @@ class IAPI(metaclass=ABCMeta):
pass pass


@abstractmethod @abstractmethod
def GetMessage(self) -> Tuple[int, str]:
def GetMessage(self) -> Tuple[int, Union[str, bytes]]:
pass pass


# 等待下一帧 # 等待下一帧


Loading…
Cancel
Save