Browse Source

Merge pull request #578 from DragonAura/dev

style(CAPI): 🎨 change int to int32_t
tags/v0.1.0
Timothy Liu GitHub 2 years ago
parent
commit
536ba08d79
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 248 additions and 248 deletions
  1. +15
    -15
      CAPI/cpp/API/include/API.h
  2. +4
    -4
      CAPI/cpp/API/include/Communication.h
  3. +196
    -196
      CAPI/cpp/API/include/constants.h
  4. +4
    -4
      CAPI/cpp/API/include/logic.h
  5. +15
    -15
      CAPI/cpp/API/include/utils.hpp
  6. +4
    -4
      CAPI/cpp/API/src/API.cpp
  7. +4
    -4
      CAPI/cpp/API/src/DebugAPI.cpp
  8. +6
    -6
      CAPI/cpp/API/src/logic.cpp

+ 15
- 15
CAPI/cpp/API/include/API.h View File

@@ -26,7 +26,7 @@
#undef SendMessage #undef SendMessage
#undef PeekMessage #undef PeekMessage


const constexpr int numOfGridPerCell = 1000;
const constexpr int32_t numOfGridPerCell = 1000;


class IAI; class IAI;


@@ -67,7 +67,7 @@ public:


virtual bool WaitThread() = 0; virtual bool WaitThread() = 0;


virtual int GetCounter() const = 0;
virtual int32_t GetCounter() const = 0;


// IStudentAPI使用的部分 // IStudentAPI使用的部分
virtual bool Graduate() = 0; virtual bool Graduate() = 0;
@@ -88,7 +88,7 @@ public:


virtual std::vector<int64_t> GetPlayerGUIDs() const = 0; virtual std::vector<int64_t> GetPlayerGUIDs() const = 0;


[[nodiscard]] virtual bool HaveView(int gridX, int gridY, int selfX, int selfY, int viewRange) const = 0;
[[nodiscard]] virtual bool HaveView(int32_t gridX, int32_t gridY, int32_t selfX, int32_t selfY, int32_t viewRange) const = 0;
}; };


class IAPI class IAPI
@@ -153,23 +153,23 @@ public:
[[nodiscard]] virtual std::vector<int64_t> GetPlayerGUIDs() const = 0; [[nodiscard]] virtual std::vector<int64_t> GetPlayerGUIDs() const = 0;


// 获取游戏目前所进行的帧数 // 获取游戏目前所进行的帧数
[[nodiscard]] virtual int GetFrameCount() const = 0;
[[nodiscard]] virtual int32_t GetFrameCount() const = 0;


/*****选手可能用的辅助函数*****/ /*****选手可能用的辅助函数*****/


// 获取指定格子中心的坐标 // 获取指定格子中心的坐标
[[nodiscard]] static inline int CellToGrid(int cell) noexcept
[[nodiscard]] static inline int32_t CellToGrid(int32_t cell) noexcept
{ {
return cell * numOfGridPerCell + numOfGridPerCell / 2; return cell * numOfGridPerCell + numOfGridPerCell / 2;
} }


// 获取指定坐标点所位于的格子的 X 序号 // 获取指定坐标点所位于的格子的 X 序号
[[nodiscard]] static inline int GridToCell(int grid) noexcept
[[nodiscard]] static inline int32_t GridToCell(int32_t grid) noexcept
{ {
return grid / numOfGridPerCell; return grid / numOfGridPerCell;
} }


[[nodiscard]] virtual bool HaveView(int gridX, int gridY) const = 0;
[[nodiscard]] virtual bool HaveView(int32_t gridX, int32_t gridY) const = 0;


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


@@ -224,7 +224,7 @@ public:
} }
void Play(IAI& ai) override; void Play(IAI& ai) override;


[[nodiscard]] int GetFrameCount() const override;
[[nodiscard]] int32_t GetFrameCount() const override;


std::future<bool> Move(int64_t timeInMilliseconds, double angleInRadian) override; std::future<bool> Move(int64_t timeInMilliseconds, double angleInRadian) override;


@@ -281,7 +281,7 @@ public:
std::future<bool> Graduate() override; std::future<bool> Graduate() override;
[[nodiscard]] std::shared_ptr<const THUAI6::Student> GetSelfInfo() const override; [[nodiscard]] std::shared_ptr<const THUAI6::Student> GetSelfInfo() const override;


[[nodiscard]] bool HaveView(int gridX, int gridY) const override;
[[nodiscard]] bool HaveView(int32_t gridX, int32_t gridY) const override;


void Print(std::string str) const override void Print(std::string str) const override
{ {
@@ -318,7 +318,7 @@ public:
} }
void Play(IAI& ai) override; void Play(IAI& ai) override;


[[nodiscard]] int GetFrameCount() const override;
[[nodiscard]] int32_t GetFrameCount() const override;


std::future<bool> Move(int64_t timeInMilliseconds, double angleInRadian) override; std::future<bool> Move(int64_t timeInMilliseconds, double angleInRadian) override;
std::future<bool> MoveRight(int64_t timeInMilliseconds) override; std::future<bool> MoveRight(int64_t timeInMilliseconds) override;
@@ -369,7 +369,7 @@ public:
std::future<bool> Attack(double angleInRadian) override; std::future<bool> Attack(double angleInRadian) override;
[[nodiscard]] std::shared_ptr<const THUAI6::Tricker> GetSelfInfo() const override; [[nodiscard]] std::shared_ptr<const THUAI6::Tricker> GetSelfInfo() const override;


[[nodiscard]] bool HaveView(int gridX, int gridY) const override;
[[nodiscard]] bool HaveView(int32_t gridX, int32_t gridY) const override;


void Print(std::string str) const override void Print(std::string str) const override
{ {
@@ -399,7 +399,7 @@ public:
void EndTimer() override; void EndTimer() override;
void Play(IAI& ai) override; void Play(IAI& ai) override;


[[nodiscard]] int GetFrameCount() const override;
[[nodiscard]] int32_t GetFrameCount() const override;


std::future<bool> Move(int64_t timeInMilliseconds, double angleInRadian) override; std::future<bool> Move(int64_t timeInMilliseconds, double angleInRadian) override;
std::future<bool> MoveRight(int64_t timeInMilliseconds) override; std::future<bool> MoveRight(int64_t timeInMilliseconds) override;
@@ -455,7 +455,7 @@ public:
std::future<bool> Graduate() override; std::future<bool> Graduate() override;
[[nodiscard]] virtual std::shared_ptr<const THUAI6::Student> GetSelfInfo() const override; [[nodiscard]] virtual std::shared_ptr<const THUAI6::Student> GetSelfInfo() const override;


[[nodiscard]] bool HaveView(int gridX, int gridY) const override;
[[nodiscard]] bool HaveView(int32_t gridX, int32_t gridY) const override;


void Print(std::string str) const override; void Print(std::string str) const override;
void PrintStudent() const override; void PrintStudent() const override;
@@ -477,7 +477,7 @@ public:
void EndTimer() override; void EndTimer() override;
void Play(IAI& ai) override; void Play(IAI& ai) override;


[[nodiscard]] int GetFrameCount() const override;
[[nodiscard]] int32_t GetFrameCount() const override;


std::future<bool> Move(int64_t timeInMilliseconds, double angleInRadian) override; std::future<bool> Move(int64_t timeInMilliseconds, double angleInRadian) override;
std::future<bool> MoveRight(int64_t timeInMilliseconds) override; std::future<bool> MoveRight(int64_t timeInMilliseconds) override;
@@ -528,7 +528,7 @@ public:
std::future<bool> Attack(double angleInRadian) override; std::future<bool> Attack(double angleInRadian) override;
[[nodiscard]] std::shared_ptr<const THUAI6::Tricker> GetSelfInfo() const override; [[nodiscard]] std::shared_ptr<const THUAI6::Tricker> GetSelfInfo() const override;


[[nodiscard]] bool HaveView(int gridX, int gridY) const override;
[[nodiscard]] bool HaveView(int32_t gridX, int32_t gridY) const override;


void Print(std::string str) const override; void Print(std::string str) const override;
void PrintStudent() const override; void PrintStudent() const override;


+ 4
- 4
CAPI/cpp/API/include/Communication.h View File

@@ -58,10 +58,10 @@ private:
protobuf::MessageToClient message2Client; protobuf::MessageToClient message2Client;
std::mutex mtxMessage; std::mutex mtxMessage;
std::mutex mtxLimit; std::mutex mtxLimit;
int counter;
int counterMove;
static constexpr const int limit = 50;
static constexpr const int moveLimit = 10;
int32_t counter;
int32_t counterMove;
static constexpr const int32_t limit = 50;
static constexpr const int32_t moveLimit = 10;
std::condition_variable cvMessage; std::condition_variable cvMessage;
}; };




+ 196
- 196
CAPI/cpp/API/include/constants.h View File

@@ -12,365 +12,365 @@


namespace Constants namespace Constants
{ {
SCCI int frameDuration = 50; // 每帧毫秒数
SCCI int32_t frameDuration = 50; // 每帧毫秒数
// 地图相关 // 地图相关
SCCI int numOfGridPerCell = 1000; // 单位坐标数
SCCI int rows = 50; // 地图行数
SCCI int cols = 50; // 地图列数
SCCI int32_t numOfGridPerCell = 1000; // 单位坐标数
SCCI int32_t rows = 50; // 地图行数
SCCI int32_t cols = 50; // 地图列数


SCCI int numOfClassroom = 10; // 教室数量
SCCI int numOfChest = 8; // 宝箱数量
SCCI int32_t numOfClassroom = 10; // 教室数量
SCCI int32_t numOfChest = 8; // 宝箱数量


SCCI int maxClassroomProgress = 10000000; // 教室最大进度
SCCI int maxDoorProgress = 10000000; // 开关门最大进度
SCCI int maxChestProgress = 10000000; // 宝箱最大进度
SCCI int maxGateProgress = 18000; // 大门最大进度
SCCI int32_t maxClassroomProgress = 10000000; // 教室最大进度
SCCI int32_t maxDoorProgress = 10000000; // 开关门最大进度
SCCI int32_t maxChestProgress = 10000000; // 宝箱最大进度
SCCI int32_t maxGateProgress = 18000; // 大门最大进度


SCCI int numOfRequiredClassroomForGate = 7; // 打开大门需要完成的教室数量
SCCI int numOfRequiredClassroomForHiddenGate = 3; // 打开隐藏门需要完成的教室数量
SCCI int32_t numOfRequiredClassroomForGate = 7; // 打开大门需要完成的教室数量
SCCI int32_t numOfRequiredClassroomForHiddenGate = 3; // 打开隐藏门需要完成的教室数量


// 人物属性相关 // 人物属性相关
SCCI int basicEncourageSpeed = 100;
SCCI int basicFixSpeed = 123;
SCCI int basicSpeedOfOpeningOrLocking = 5000;
SCCI int basicStudentSpeedOfClimbingThroughWindows = 1222;
SCCI int basicTrickerSpeedOfClimbingThroughWindows = 2540;
SCCI int basicSpeedOfOpenChest = 1250;
SCCI int32_t basicEncourageSpeed = 100;
SCCI int32_t basicFixSpeed = 123;
SCCI int32_t basicSpeedOfOpeningOrLocking = 5000;
SCCI int32_t basicStudentSpeedOfClimbingThroughWindows = 1222;
SCCI int32_t basicTrickerSpeedOfClimbingThroughWindows = 2540;
SCCI int32_t basicSpeedOfOpenChest = 1250;


SCCI int basicHp = 3000000;
SCCI int basicMaxGamingAddiction = 60000;
SCCI int basicEncouragementDegree = 1500000;
SCCI int basicTimeOfRouse = 1000;
SCCI int32_t basicHp = 3000000;
SCCI int32_t basicMaxGamingAddiction = 60000;
SCCI int32_t basicEncouragementDegree = 1500000;
SCCI int32_t basicTimeOfRouse = 1000;


SCCI int basicStudentSpeed = 3000;
SCCI int basicTrickerSpeed = 3600;
SCCI int32_t basicStudentSpeed = 3000;
SCCI int32_t basicTrickerSpeed = 3600;


SCCI double basicConcealment = 1; SCCI double basicConcealment = 1;
SCCI int basicStudentAlertnessRadius = 15 * numOfGridPerCell;
SCCI int basicTrickerAlertnessRadius = 17 * numOfGridPerCell;
SCCI int basicStudentViewRange = 10 * numOfGridPerCell;
SCCI int basicTrickerViewRange = 13 * numOfGridPerCell;
SCCI int PinningDownRange = 5 * numOfGridPerCell;
SCCI int32_t basicStudentAlertnessRadius = 15 * numOfGridPerCell;
SCCI int32_t basicTrickerAlertnessRadius = 17 * numOfGridPerCell;
SCCI int32_t basicStudentViewRange = 10 * numOfGridPerCell;
SCCI int32_t basicTrickerViewRange = 13 * numOfGridPerCell;
SCCI int32_t PinningDownRange = 5 * numOfGridPerCell;


SCCI int maxNumOfProp = 3; // 人物道具栏容量
SCCI int32_t maxNumOfProp = 3; // 人物道具栏容量


// 攻击相关 // 攻击相关


SCCI int basicApOfTricker = 1500000;
SCCI int basicCD = 3000; // 初始子弹冷却
SCCI int basicCastTime = 500; // 基本前摇时间
SCCI int basicBackswing = 800; // 基本后摇时间
SCCI int basicRecoveryFromHit = 3700; // 基本命中攻击恢复时长
SCCI int basicStunnedTimeOfStudent = 4300;
SCCI int32_t basicApOfTricker = 1500000;
SCCI int32_t basicCD = 3000; // 初始子弹冷却
SCCI int32_t basicCastTime = 500; // 基本前摇时间
SCCI int32_t basicBackswing = 800; // 基本后摇时间
SCCI int32_t basicRecoveryFromHit = 3700; // 基本命中攻击恢复时长
SCCI int32_t basicStunnedTimeOfStudent = 4300;


SCCI int basicBulletMoveSpeed = 7400; // 基本子弹移动速度
SCCI int32_t basicBulletMoveSpeed = 7400; // 基本子弹移动速度
SCCI double basicRemoteAttackRange = 6000; // 基本远程攻击范围 SCCI double basicRemoteAttackRange = 6000; // 基本远程攻击范围
SCCI double basicAttackShortRange = 2200; // 基本近程攻击范围 SCCI double basicAttackShortRange = 2200; // 基本近程攻击范围
SCCI double basicBulletBombRange = 2000; // 基本子弹爆炸范围 SCCI double basicBulletBombRange = 2000; // 基本子弹爆炸范围


// 道具相关 // 道具相关


SCCI int apPropAdd = basicApOfTricker * 12 / 10;
SCCI int apSpearAdd = basicApOfTricker * 6 / 10;
SCCI int32_t apPropAdd = basicApOfTricker * 12 / 10;
SCCI int32_t apSpearAdd = basicApOfTricker * 6 / 10;


// 职业相关 // 职业相关
struct Assassin struct Assassin
{ {
SCCI int moveSpeed = basicTrickerSpeed * 11 / 10;
SCCI int32_t moveSpeed = basicTrickerSpeed * 11 / 10;
SCCI double concealment = 1.5; SCCI double concealment = 1.5;
SCCI int alertnessRadius = basicTrickerAlertnessRadius * 13 / 10;
SCCI int viewRange = basicTrickerViewRange * 12 / 10;
SCCI int speedOfOpeningOrLocking = basicSpeedOfOpeningOrLocking;
SCCI int speedOfClimbingThroughWindows = basicTrickerSpeedOfClimbingThroughWindows;
SCCI int speedOfOpenChest = basicSpeedOfOpenChest;
SCCI int32_t alertnessRadius = basicTrickerAlertnessRadius * 13 / 10;
SCCI int32_t viewRange = basicTrickerViewRange * 12 / 10;
SCCI int32_t speedOfOpeningOrLocking = basicSpeedOfOpeningOrLocking;
SCCI int32_t speedOfClimbingThroughWindows = basicTrickerSpeedOfClimbingThroughWindows;
SCCI int32_t speedOfOpenChest = basicSpeedOfOpenChest;
}; };


struct Klee struct Klee
{ {
SCCI int moveSpeed = basicTrickerSpeed;
SCCI int32_t moveSpeed = basicTrickerSpeed;
SCCI double concealment = 1; SCCI double concealment = 1;
SCCI int alertnessRadius = basicTrickerAlertnessRadius;
SCCI int viewRange = basicTrickerViewRange;
SCCI int speedOfOpeningOrLocking = basicSpeedOfOpeningOrLocking;
SCCI int speedOfClimbingThroughWindows = basicTrickerSpeedOfClimbingThroughWindows;
SCCI int speedOfOpenChest = basicSpeedOfOpenChest * 11 / 10;
SCCI int32_t alertnessRadius = basicTrickerAlertnessRadius;
SCCI int32_t viewRange = basicTrickerViewRange;
SCCI int32_t speedOfOpeningOrLocking = basicSpeedOfOpeningOrLocking;
SCCI int32_t speedOfClimbingThroughWindows = basicTrickerSpeedOfClimbingThroughWindows;
SCCI int32_t speedOfOpenChest = basicSpeedOfOpenChest * 11 / 10;
}; };


struct ANoisyPerson struct ANoisyPerson
{ {
SCCI int moveSpeed = (int)(basicTrickerSpeed * 1.07);
SCCI int32_t moveSpeed = (int32_t)(basicTrickerSpeed * 1.07);
SCCI double concealment = 0.8; SCCI double concealment = 0.8;
SCCI int alertnessRadius = basicTrickerAlertnessRadius * 9 / 10;
SCCI int viewRange = basicTrickerViewRange;
SCCI int speedOfOpeningOrLocking = basicSpeedOfOpeningOrLocking;
SCCI int speedOfClimbingThroughWindows = basicTrickerSpeedOfClimbingThroughWindows * 11 / 10;
SCCI int speedOfOpenChest = basicSpeedOfOpenChest * 11 / 10;
SCCI int32_t alertnessRadius = basicTrickerAlertnessRadius * 9 / 10;
SCCI int32_t viewRange = basicTrickerViewRange;
SCCI int32_t speedOfOpeningOrLocking = basicSpeedOfOpeningOrLocking;
SCCI int32_t speedOfClimbingThroughWindows = basicTrickerSpeedOfClimbingThroughWindows * 11 / 10;
SCCI int32_t speedOfOpenChest = basicSpeedOfOpenChest * 11 / 10;
}; };


struct Idol struct Idol
{ {
SCCI int moveSpeed = basicTrickerSpeed;
SCCI int32_t moveSpeed = basicTrickerSpeed;
SCCI double concealment = 0.75; SCCI double concealment = 0.75;
SCCI int alertnessRadius = basicTrickerAlertnessRadius;
SCCI int viewRange = basicTrickerViewRange * 11 / 10;
SCCI int speedOfOpeningOrLocking = basicSpeedOfOpeningOrLocking;
SCCI int speedOfClimbingThroughWindows = basicTrickerSpeedOfClimbingThroughWindows;
SCCI int speedOfOpenChest = basicSpeedOfOpenChest;
SCCI int32_t alertnessRadius = basicTrickerAlertnessRadius;
SCCI int32_t viewRange = basicTrickerViewRange * 11 / 10;
SCCI int32_t speedOfOpeningOrLocking = basicSpeedOfOpeningOrLocking;
SCCI int32_t speedOfClimbingThroughWindows = basicTrickerSpeedOfClimbingThroughWindows;
SCCI int32_t speedOfOpenChest = basicSpeedOfOpenChest;
}; };


struct Athlete struct Athlete
{ {
SCCI int moveSpeed = basicStudentSpeed * 105 / 100;
SCCI int maxHp = basicHp;
SCCI int maxAddiction = basicMaxGamingAddiction * 9 / 10;
SCCI int fixSpeed = basicFixSpeed * 6 / 10;
SCCI int encourageSpeed = basicEncourageSpeed * 9 / 10;
SCCI int32_t moveSpeed = basicStudentSpeed * 105 / 100;
SCCI int32_t maxHp = basicHp;
SCCI int32_t maxAddiction = basicMaxGamingAddiction * 9 / 10;
SCCI int32_t fixSpeed = basicFixSpeed * 6 / 10;
SCCI int32_t encourageSpeed = basicEncourageSpeed * 9 / 10;
SCCI double concealment = 0.9; SCCI double concealment = 0.9;
SCCI int alertnessRadius = basicStudentAlertnessRadius;
SCCI int viewRange = basicStudentViewRange * 11 / 10;
SCCI int speedOfOpeningOrLocking = basicSpeedOfOpeningOrLocking;
SCCI int speedOfClimbingThroughWindows = basicStudentSpeedOfClimbingThroughWindows * 12 / 10;
SCCI int speedOfOpenChest = basicSpeedOfOpenChest;
SCCI int32_t alertnessRadius = basicStudentAlertnessRadius;
SCCI int32_t viewRange = basicStudentViewRange * 11 / 10;
SCCI int32_t speedOfOpeningOrLocking = basicSpeedOfOpeningOrLocking;
SCCI int32_t speedOfClimbingThroughWindows = basicStudentSpeedOfClimbingThroughWindows * 12 / 10;
SCCI int32_t speedOfOpenChest = basicSpeedOfOpenChest;
}; };


struct Teacher struct Teacher
{ {
SCCI int moveSpeed = basicStudentSpeed * 9 / 10;
SCCI int maxHp = basicHp * 10;
SCCI int maxAddiction = basicMaxGamingAddiction * 10;
SCCI int fixSpeed = (int)(basicFixSpeed * 50 / 123);
SCCI int encourageSpeed = basicEncourageSpeed * 8 / 10;
SCCI int32_t moveSpeed = basicStudentSpeed * 9 / 10;
SCCI int32_t maxHp = basicHp * 10;
SCCI int32_t maxAddiction = basicMaxGamingAddiction * 10;
SCCI int32_t fixSpeed = (int32_t)(basicFixSpeed * 50 / 123);
SCCI int32_t encourageSpeed = basicEncourageSpeed * 8 / 10;
SCCI double concealment = 0.5; SCCI double concealment = 0.5;
SCCI int alertnessRadius = basicStudentAlertnessRadius * 2 / 3;
SCCI int viewRange = basicStudentViewRange * 8 / 10;
SCCI int speedOfOpeningOrLocking = basicSpeedOfOpeningOrLocking;
SCCI int speedOfClimbingThroughWindows = (int)(basicStudentSpeedOfClimbingThroughWindows * 1000 / 1222);
SCCI int speedOfOpenChest = basicSpeedOfOpenChest;
SCCI int32_t alertnessRadius = basicStudentAlertnessRadius * 2 / 3;
SCCI int32_t viewRange = basicStudentViewRange * 8 / 10;
SCCI int32_t speedOfOpeningOrLocking = basicSpeedOfOpeningOrLocking;
SCCI int32_t speedOfClimbingThroughWindows = (int32_t)(basicStudentSpeedOfClimbingThroughWindows * 1000 / 1222);
SCCI int32_t speedOfOpenChest = basicSpeedOfOpenChest;
}; };


struct StraightAStudent struct StraightAStudent
{ {
SCCI int moveSpeed = basicStudentSpeed * 24 / 25;
SCCI int maxHp = basicHp * 11 / 10;
SCCI int maxAddiction = basicMaxGamingAddiction * 13 / 10;
SCCI int fixSpeed = basicFixSpeed * 11 / 10;
SCCI int encourageSpeed = basicEncourageSpeed;
SCCI int32_t moveSpeed = basicStudentSpeed * 24 / 25;
SCCI int32_t maxHp = basicHp * 11 / 10;
SCCI int32_t maxAddiction = basicMaxGamingAddiction * 13 / 10;
SCCI int32_t fixSpeed = basicFixSpeed * 11 / 10;
SCCI int32_t encourageSpeed = basicEncourageSpeed;
SCCI double concealment = 0.9; SCCI double concealment = 0.9;
SCCI int alertnessRadius = basicStudentAlertnessRadius * 9 / 10;
SCCI int viewRange = basicStudentViewRange * 9 / 10;
SCCI int speedOfOpeningOrLocking = basicSpeedOfOpeningOrLocking;
SCCI int speedOfClimbingThroughWindows = basicStudentSpeedOfClimbingThroughWindows * 10 / 12;
SCCI int speedOfOpenChest = basicSpeedOfOpenChest;
SCCI int32_t alertnessRadius = basicStudentAlertnessRadius * 9 / 10;
SCCI int32_t viewRange = basicStudentViewRange * 9 / 10;
SCCI int32_t speedOfOpeningOrLocking = basicSpeedOfOpeningOrLocking;
SCCI int32_t speedOfClimbingThroughWindows = basicStudentSpeedOfClimbingThroughWindows * 10 / 12;
SCCI int32_t speedOfOpenChest = basicSpeedOfOpenChest;
}; };


struct Robot struct Robot
{ {
SCCI int moveSpeed = basicStudentSpeed * 9 / 10;
SCCI int maxHp = basicHp * 3 / 10;
SCCI int maxAddiction = basicMaxGamingAddiction * 0;
SCCI int fixSpeed = basicFixSpeed * 7 / 10;
SCCI int encourageSpeed = 0;
SCCI int32_t moveSpeed = basicStudentSpeed * 9 / 10;
SCCI int32_t maxHp = basicHp * 3 / 10;
SCCI int32_t maxAddiction = basicMaxGamingAddiction * 0;
SCCI int32_t fixSpeed = basicFixSpeed * 7 / 10;
SCCI int32_t encourageSpeed = 0;
SCCI double concealment = 0.8; SCCI double concealment = 0.8;
SCCI int alertnessRadius = 0;
SCCI int viewRange = 0;
SCCI int speedOfOpeningOrLocking = 0;
SCCI int speedOfClimbingThroughWindows = 1;
SCCI int speedOfOpenChest = basicSpeedOfOpenChest * 4 / 5;
SCCI int32_t alertnessRadius = 0;
SCCI int32_t viewRange = 0;
SCCI int32_t speedOfOpeningOrLocking = 0;
SCCI int32_t speedOfClimbingThroughWindows = 1;
SCCI int32_t speedOfOpenChest = basicSpeedOfOpenChest * 4 / 5;
}; };


struct TechOtaku struct TechOtaku
{ {
SCCI int moveSpeed = (int)(basicStudentSpeed * 0.96);
SCCI int maxHp = basicHp * 9 / 10;
SCCI int maxAddiction = basicMaxGamingAddiction;
SCCI int fixSpeed = (int)(basicFixSpeed * 0.9);
SCCI int encourageSpeed = basicEncourageSpeed;
SCCI int32_t moveSpeed = (int32_t)(basicStudentSpeed * 0.96);
SCCI int32_t maxHp = basicHp * 9 / 10;
SCCI int32_t maxAddiction = basicMaxGamingAddiction;
SCCI int32_t fixSpeed = (int32_t)(basicFixSpeed * 0.9);
SCCI int32_t encourageSpeed = basicEncourageSpeed;
SCCI double concealment = 1.1; SCCI double concealment = 1.1;
SCCI int alertnessRadius = basicStudentAlertnessRadius;
SCCI int viewRange = basicStudentViewRange * 9 / 10;
SCCI int speedOfOpeningOrLocking = basicSpeedOfOpeningOrLocking;
SCCI int speedOfClimbingThroughWindows = (int)(basicStudentSpeedOfClimbingThroughWindows * 0.9);
SCCI int speedOfOpenChest = basicSpeedOfOpenChest * 22 / 25;
SCCI int32_t alertnessRadius = basicStudentAlertnessRadius;
SCCI int32_t viewRange = basicStudentViewRange * 9 / 10;
SCCI int32_t speedOfOpeningOrLocking = basicSpeedOfOpeningOrLocking;
SCCI int32_t speedOfClimbingThroughWindows = (int32_t)(basicStudentSpeedOfClimbingThroughWindows * 0.9);
SCCI int32_t speedOfOpenChest = basicSpeedOfOpenChest * 22 / 25;
}; };


struct Sunshine struct Sunshine
{ {
SCCI int moveSpeed = basicStudentSpeed;
SCCI int maxHp = basicHp * 16 / 15;
SCCI int maxAddiction = basicMaxGamingAddiction * 11 / 10;
SCCI int fixSpeed = basicFixSpeed;
SCCI int encourageSpeed = basicEncourageSpeed * 6 / 5;
SCCI int32_t moveSpeed = basicStudentSpeed;
SCCI int32_t maxHp = basicHp * 16 / 15;
SCCI int32_t maxAddiction = basicMaxGamingAddiction * 11 / 10;
SCCI int32_t fixSpeed = basicFixSpeed;
SCCI int32_t encourageSpeed = basicEncourageSpeed * 6 / 5;
SCCI double concealment = 1; SCCI double concealment = 1;
SCCI int alertnessRadius = basicStudentAlertnessRadius;
SCCI int viewRange = basicStudentViewRange;
SCCI int speedOfOpeningOrLocking = basicSpeedOfOpeningOrLocking * 7 / 10;
SCCI int speedOfClimbingThroughWindows = basicStudentSpeedOfClimbingThroughWindows;
SCCI int speedOfOpenChest = basicSpeedOfOpenChest * 9 / 10;
SCCI int32_t alertnessRadius = basicStudentAlertnessRadius;
SCCI int32_t viewRange = basicStudentViewRange;
SCCI int32_t speedOfOpeningOrLocking = basicSpeedOfOpeningOrLocking * 7 / 10;
SCCI int32_t speedOfClimbingThroughWindows = basicStudentSpeedOfClimbingThroughWindows;
SCCI int32_t speedOfOpenChest = basicSpeedOfOpenChest * 9 / 10;
}; };


// 技能相关 // 技能相关
SCCI int maxNumOfSkill = 3;
SCCI int commonSkillCD = 30000; // 普通技能标准冷却时间
SCCI int commonSkillTime = 10000; // 普通技能标准持续时间
SCCI int32_t maxNumOfSkill = 3;
SCCI int32_t commonSkillCD = 30000; // 普通技能标准冷却时间
SCCI int32_t commonSkillTime = 10000; // 普通技能标准持续时间


SCCI int timeOfTrickerStunnedWhenCharge = 7220;
SCCI int timeOfStudentStunnedWhenCharge = 2090;
SCCI int32_t timeOfTrickerStunnedWhenCharge = 7220;
SCCI int32_t timeOfStudentStunnedWhenCharge = 2090;


SCCI int timeOfTrickerStunnedWhenPunish = 3070;
SCCI int32_t timeOfTrickerStunnedWhenPunish = 3070;


SCCI int timeOfTrickerSwingingAfterHowl = 800;
SCCI int timeOfStudentStunnedWhenHowl = 5500;
SCCI int32_t timeOfTrickerSwingingAfterHowl = 800;
SCCI int32_t timeOfStudentStunnedWhenHowl = 5500;


SCCI int timeOfStunnedWhenJumpyDumpty = 3070;
SCCI int32_t timeOfStunnedWhenJumpyDumpty = 3070;


SCCI double addedTimeOfSpeedWhenInspire = 1.6; SCCI double addedTimeOfSpeedWhenInspire = 1.6;
SCCI int timeOfAddingSpeedWhenInspire = 6000;
SCCI int32_t timeOfAddingSpeedWhenInspire = 6000;


SCCI int addHpWhenEncourage = basicHp / 4;
SCCI int32_t addHpWhenEncourage = basicHp / 4;


SCCI int checkIntervalWhenShowTime = 200;
SCCI int addAddictionPer100msWhenShowTime = 300;
SCCI int32_t checkIntervalWhenShowTime = 200;
SCCI int32_t addAddictionPer100msWhenShowTime = 300;
struct CanBeginToCharge struct CanBeginToCharge
{ {
SCCI int skillCD = commonSkillCD * 2;
SCCI int durationTime = commonSkillTime * 3 / 10;
SCCI int32_t skillCD = commonSkillCD * 2;
SCCI int32_t durationTime = commonSkillTime * 3 / 10;
}; };


struct BecomeInvisible struct BecomeInvisible
{ {
SCCI int skillCD = commonSkillCD * 4 / 3;
SCCI int durationTime = commonSkillTime;
SCCI int32_t skillCD = commonSkillCD * 4 / 3;
SCCI int32_t durationTime = commonSkillTime;
}; };


struct Punish struct Punish
{ {
SCCI int skillCD = commonSkillCD * 3 / 2;
SCCI int durationTime = commonSkillTime * 0;
SCCI int32_t skillCD = commonSkillCD * 3 / 2;
SCCI int32_t durationTime = commonSkillTime * 0;
}; };


struct SparksNSplash struct SparksNSplash
{ {
SCCI int skillCD = commonSkillCD * 3 / 2;
SCCI int durationTime = commonSkillTime * 1;
SCCI int32_t skillCD = commonSkillCD * 3 / 2;
SCCI int32_t durationTime = commonSkillTime * 1;
}; };


struct HaveTea struct HaveTea
{ {
SCCI int skillCD = commonSkillCD * 3;
SCCI int durationTime = commonSkillTime * 0;
SCCI int32_t skillCD = commonSkillCD * 3;
SCCI int32_t durationTime = commonSkillTime * 0;
}; };


struct Rouse struct Rouse
{ {
SCCI int skillCD = commonSkillCD * 4;
SCCI int durationTime = commonSkillTime * 0;
SCCI int32_t skillCD = commonSkillCD * 4;
SCCI int32_t durationTime = commonSkillTime * 0;
}; };


struct Encourage struct Encourage
{ {
SCCI int skillCD = commonSkillCD * 4;
SCCI int durationTime = commonSkillTime * 0;
SCCI int32_t skillCD = commonSkillCD * 4;
SCCI int32_t durationTime = commonSkillTime * 0;
}; };


struct Inspire struct Inspire
{ {
SCCI int skillCD = commonSkillCD * 4;
SCCI int durationTime = commonSkillTime * 0;
SCCI int32_t skillCD = commonSkillCD * 4;
SCCI int32_t durationTime = commonSkillTime * 0;
}; };


struct Howl struct Howl
{ {
SCCI int skillCD = commonSkillCD * 25 / 30;
SCCI int durationTime = commonSkillTime * 0;
SCCI int32_t skillCD = commonSkillCD * 25 / 30;
SCCI int32_t durationTime = commonSkillTime * 0;
}; };


struct ShowTime struct ShowTime
{ {
SCCI int skillCD = commonSkillCD * 8 / 3;
SCCI int durationTime = commonSkillTime * 1;
SCCI int32_t skillCD = commonSkillCD * 8 / 3;
SCCI int32_t durationTime = commonSkillTime * 1;
}; };


struct JumpyBomb struct JumpyBomb
{ {
SCCI int skillCD = commonSkillCD / 2;
SCCI int durationTime = commonSkillTime * 3 / 10;
SCCI int32_t skillCD = commonSkillCD / 2;
SCCI int32_t durationTime = commonSkillTime * 3 / 10;
}; };


struct UseKnife struct UseKnife
{ {
SCCI int skillCD = commonSkillCD * 1;
SCCI int durationTime = commonSkillTime / 10;
SCCI int32_t skillCD = commonSkillCD * 1;
SCCI int32_t durationTime = commonSkillTime / 10;
}; };


struct UseRobot struct UseRobot
{ {
SCCI int skillCD = commonSkillCD / 15;
SCCI int durationTime = commonSkillTime * 0;
SCCI int32_t skillCD = commonSkillCD / 15;
SCCI int32_t durationTime = commonSkillTime * 0;
}; };


struct WriteAnswers struct WriteAnswers
{ {
SCCI int skillCD = commonSkillCD * 1;
SCCI int durationTime = commonSkillTime * 0;
SCCI int32_t skillCD = commonSkillCD * 1;
SCCI int32_t durationTime = commonSkillTime * 0;
}; };


struct SummonGolem struct SummonGolem
{ {
SCCI int skillCD = commonSkillCD * 4 / 3;
SCCI int durationTime = commonSkillTime * 6;
SCCI int32_t skillCD = commonSkillCD * 4 / 3;
SCCI int32_t durationTime = commonSkillTime * 6;
}; };


struct CommonAttackOfTricker struct CommonAttackOfTricker
{ {
SCCI double BulletBombRange = 0; SCCI double BulletBombRange = 0;
SCCI double BulletAttackRange = basicAttackShortRange; SCCI double BulletAttackRange = basicAttackShortRange;
SCCI int ap = basicApOfTricker;
SCCI int Speed = basicBulletMoveSpeed;
SCCI int32_t ap = basicApOfTricker;
SCCI int32_t Speed = basicBulletMoveSpeed;
SCCI bool IsRemoteAttack = false; SCCI bool IsRemoteAttack = false;


SCCI int CastTime = (int)BulletAttackRange * 1000 / Speed;
SCCI int Backswing = basicBackswing;
SCCI int RecoveryFromHit = basicRecoveryFromHit;
SCCI int cd = basicBackswing;
SCCI int maxBulletNum = 1;
SCCI int32_t CastTime = (int32_t)BulletAttackRange * 1000 / Speed;
SCCI int32_t Backswing = basicBackswing;
SCCI int32_t RecoveryFromHit = basicRecoveryFromHit;
SCCI int32_t cd = basicBackswing;
SCCI int32_t maxBulletNum = 1;
}; };


struct FlyingKnife struct FlyingKnife
{ {
SCCI double BulletBombRange = 0; SCCI double BulletBombRange = 0;
SCCI double BulletAttackRange = basicRemoteAttackRange * 13; SCCI double BulletAttackRange = basicRemoteAttackRange * 13;
SCCI int ap = basicApOfTricker * 4 / 5;
SCCI int Speed = basicBulletMoveSpeed * 25 / 10;
SCCI int32_t ap = basicApOfTricker * 4 / 5;
SCCI int32_t Speed = basicBulletMoveSpeed * 25 / 10;
SCCI bool IsRemoteAttack = true; SCCI bool IsRemoteAttack = true;


SCCI int CastTime = basicCastTime * 6 / 5;
SCCI int Backswing = 0;
SCCI int RecoveryFromHit = 0;
SCCI int cd = basicBackswing * 3 / 4;
SCCI int maxBulletNum = 1;
SCCI int32_t CastTime = basicCastTime * 6 / 5;
SCCI int32_t Backswing = 0;
SCCI int32_t RecoveryFromHit = 0;
SCCI int32_t cd = basicBackswing * 3 / 4;
SCCI int32_t maxBulletNum = 1;
}; };


struct BombBomb struct BombBomb
{ {
SCCI double BulletBombRange = basicBulletBombRange; SCCI double BulletBombRange = basicBulletBombRange;
SCCI double BulletAttackRange = basicAttackShortRange; SCCI double BulletAttackRange = basicAttackShortRange;
SCCI int ap = basicApOfTricker * 6 / 5;
SCCI int Speed = basicBulletMoveSpeed * 30 / 37;
SCCI int32_t ap = basicApOfTricker * 6 / 5;
SCCI int32_t Speed = basicBulletMoveSpeed * 30 / 37;
SCCI bool IsRemoteAttack = false; SCCI bool IsRemoteAttack = false;


SCCI int CastTime = (int)BulletAttackRange * 1000 / Speed;
SCCI int Backswing = basicBackswing * 3 / 2;
SCCI int RecoveryFromHit = basicRecoveryFromHit;
SCCI int cd = basicCD;
SCCI int maxBulletNum = 1;
SCCI int32_t CastTime = (int32_t)BulletAttackRange * 1000 / Speed;
SCCI int32_t Backswing = basicBackswing * 3 / 2;
SCCI int32_t RecoveryFromHit = basicRecoveryFromHit;
SCCI int32_t cd = basicCD;
SCCI int32_t maxBulletNum = 1;
}; };


struct JumpyDumpty struct JumpyDumpty
{ {
SCCI double BulletBombRange = basicBulletBombRange / 2; SCCI double BulletBombRange = basicBulletBombRange / 2;
SCCI double BulletAttackRange = basicAttackShortRange * 16 / 22; SCCI double BulletAttackRange = basicAttackShortRange * 16 / 22;
SCCI int ap = (int)(basicApOfTricker * 0.6);
SCCI int Speed = basicBulletMoveSpeed * 43 / 37;
SCCI int32_t ap = (int32_t)(basicApOfTricker * 0.6);
SCCI int32_t Speed = basicBulletMoveSpeed * 43 / 37;
SCCI bool IsRemoteAttack = false; SCCI bool IsRemoteAttack = false;
}; };


@@ -378,15 +378,15 @@ namespace Constants
{ {
SCCI double BulletBombRange = 0; SCCI double BulletBombRange = 0;
SCCI double BulletAttackRange = basicAttackShortRange; SCCI double BulletAttackRange = basicAttackShortRange;
SCCI int ap = basicApOfTricker * 16 / 15;
SCCI int Speed = basicBulletMoveSpeed * 125 / 148;
SCCI int32_t ap = basicApOfTricker * 16 / 15;
SCCI int32_t Speed = basicBulletMoveSpeed * 125 / 148;
SCCI bool IsRemoteAttack = false; SCCI bool IsRemoteAttack = false;


SCCI int CastTime = basicCastTime * 16 / 25;
SCCI int Backswing = basicBackswing;
SCCI int RecoveryFromHit = basicRecoveryFromHit;
SCCI int cd = basicBackswing;
SCCI int maxBulletNum = 1;
SCCI int32_t CastTime = basicCastTime * 16 / 25;
SCCI int32_t Backswing = basicBackswing;
SCCI int32_t RecoveryFromHit = basicRecoveryFromHit;
SCCI int32_t cd = basicBackswing;
SCCI int32_t maxBulletNum = 1;
}; };
} // namespace Constants } // namespace Constants
#endif #endif

+ 4
- 4
CAPI/cpp/API/include/logic.h View File

@@ -73,8 +73,8 @@ private:
State* bufferState; State* bufferState;


// 保存缓冲区数 // 保存缓冲区数
int counterState = 0;
int counterBuffer = 0;
int32_t counterState = 0;
int32_t counterBuffer = 0;


THUAI6::GameState gameState = THUAI6::GameState::NullGameState; THUAI6::GameState gameState = THUAI6::GameState::NullGameState;


@@ -140,7 +140,7 @@ private:


bool WaitThread() override; bool WaitThread() override;


int GetCounter() const override;
int32_t GetCounter() const override;


std::vector<int64_t> GetPlayerGUIDs() const override; std::vector<int64_t> GetPlayerGUIDs() const override;


@@ -162,7 +162,7 @@ private:
// 等待 // 等待
void Wait() noexcept; void Wait() noexcept;


[[nodiscard]] bool HaveView(int gridX, int gridY, int selfX, int selfY, int viewRange) const override;
[[nodiscard]] bool HaveView(int32_t gridX, int32_t gridY, int32_t selfX, int32_t selfY, int32_t viewRange) const override;


public: public:
// 构造函数还需要传更多参数,有待补充 // 构造函数还需要传更多参数,有待补充


+ 15
- 15
CAPI/cpp/API/include/utils.hpp View File

@@ -20,22 +20,22 @@
namespace AssistFunction namespace AssistFunction
{ {


constexpr int numOfGridPerCell = 1000;
constexpr int32_t numOfGridPerCell = 1000;


[[nodiscard]] constexpr inline int GridToCell(int grid) noexcept
[[nodiscard]] constexpr inline int32_t GridToCell(int32_t grid) noexcept
{ {
return grid / numOfGridPerCell; return grid / numOfGridPerCell;
} }


[[nodiscard]] constexpr inline int GridToCell(double grid) noexcept
[[nodiscard]] constexpr inline int32_t GridToCell(double grid) noexcept
{ {
return int(grid) / numOfGridPerCell; return int(grid) / numOfGridPerCell;
} }


inline bool HaveView(int viewRange, int x, int y, int newX, int newY, std::vector<std::vector<THUAI6::PlaceType>>& map)
inline bool HaveView(int32_t viewRange, int32_t x, int32_t y, int32_t newX, int32_t newY, std::vector<std::vector<THUAI6::PlaceType>>& map)
{ {
int deltaX = newX - x;
int deltaY = newY - y;
int32_t deltaX = newX - x;
int32_t deltaY = newY - y;
double distance = deltaX * deltaX + deltaY * deltaY; double distance = deltaX * deltaX + deltaY * deltaY;
THUAI6::PlaceType myPlace = map[GridToCell(x)][GridToCell(y)]; THUAI6::PlaceType myPlace = map[GridToCell(x)][GridToCell(y)];
THUAI6::PlaceType newPlace = map[GridToCell(newX)][GridToCell(newY)]; THUAI6::PlaceType newPlace = map[GridToCell(newX)][GridToCell(newY)];
@@ -43,7 +43,7 @@ namespace AssistFunction
return false; return false;
if (distance < viewRange * viewRange) if (distance < viewRange * viewRange)
{ {
int divide = std::max(std::abs(deltaX), std::abs(deltaY)) / 100;
int32_t divide = std::max(std::abs(deltaX), std::abs(deltaY)) / 100;
if (divide == 0) if (divide == 0)
return true; return true;
double dx = deltaX / divide; double dx = deltaX / divide;
@@ -51,7 +51,7 @@ namespace AssistFunction
double myX = double(x); double myX = double(x);
double myY = double(y); double myY = double(y);
if (newPlace == THUAI6::PlaceType::Grass && myPlace == THUAI6::PlaceType::Grass) // 都在草丛内,要另作判断 if (newPlace == THUAI6::PlaceType::Grass && myPlace == THUAI6::PlaceType::Grass) // 都在草丛内,要另作判断
for (int i = 0; i < divide; i++)
for (int32_t i = 0; i < divide; i++)
{ {
myX += dx; myX += dx;
myY += dy; myY += dy;
@@ -59,7 +59,7 @@ namespace AssistFunction
return false; return false;
} }
else // 不在草丛内,只需要没有墙即可 else // 不在草丛内,只需要没有墙即可
for (int i = 0; i < divide; i++)
for (int32_t i = 0; i < divide; i++)
{ {
myX += dx; myX += dx;
myY += dy; myY += dy;
@@ -226,12 +226,12 @@ namespace Proto2THUAI6
tricker->trickDesire = trickerMsg.trick_desire(); tricker->trickDesire = trickerMsg.trick_desire();
tricker->classVolume = trickerMsg.class_volume(); tricker->classVolume = trickerMsg.class_volume();
tricker->timeUntilSkillAvailable.clear(); tricker->timeUntilSkillAvailable.clear();
for (int i = 0; i < trickerMsg.time_until_skill_available().size(); i++)
for (int32_t i = 0; i < trickerMsg.time_until_skill_available().size(); i++)
tricker->timeUntilSkillAvailable.push_back(trickerMsg.time_until_skill_available(i)); tricker->timeUntilSkillAvailable.push_back(trickerMsg.time_until_skill_available(i));
// tricker->place = placeTypeDict[trickerMsg.place()]; // tricker->place = placeTypeDict[trickerMsg.place()];
tricker->playerState = playerStateDict[trickerMsg.player_state()]; tricker->playerState = playerStateDict[trickerMsg.player_state()];
tricker->props.clear(); tricker->props.clear();
for (int i = 0; i < trickerMsg.prop().size(); i++)
for (int32_t i = 0; i < trickerMsg.prop().size(); i++)
tricker->props.push_back(propTypeDict[trickerMsg.prop(i)]); tricker->props.push_back(propTypeDict[trickerMsg.prop(i)]);
tricker->trickerType = trickerTypeDict[trickerMsg.tricker_type()]; tricker->trickerType = trickerTypeDict[trickerMsg.tricker_type()];
tricker->guid = trickerMsg.guid(); tricker->guid = trickerMsg.guid();
@@ -240,7 +240,7 @@ namespace Proto2THUAI6
tricker->radius = trickerMsg.radius(); tricker->radius = trickerMsg.radius();
tricker->playerType = THUAI6::PlayerType::TrickerPlayer; tricker->playerType = THUAI6::PlayerType::TrickerPlayer;
tricker->buff.clear(); tricker->buff.clear();
for (int i = 0; i < trickerMsg.buff().size(); i++)
for (int32_t i = 0; i < trickerMsg.buff().size(); i++)
tricker->buff.push_back(trickerBuffTypeDict[trickerMsg.buff(i)]); tricker->buff.push_back(trickerBuffTypeDict[trickerMsg.buff(i)]);
return tricker; return tricker;
} }
@@ -264,11 +264,11 @@ namespace Proto2THUAI6
student->rouseProgress = studentMsg.rescue_progress(); student->rouseProgress = studentMsg.rescue_progress();
student->dangerAlert = studentMsg.danger_alert(); student->dangerAlert = studentMsg.danger_alert();
student->timeUntilSkillAvailable.clear(); student->timeUntilSkillAvailable.clear();
for (int i = 0; i < studentMsg.time_until_skill_available().size(); i++)
for (int32_t i = 0; i < studentMsg.time_until_skill_available().size(); i++)
student->timeUntilSkillAvailable.push_back(studentMsg.time_until_skill_available(i)); student->timeUntilSkillAvailable.push_back(studentMsg.time_until_skill_available(i));
student->playerType = THUAI6::PlayerType::StudentPlayer; student->playerType = THUAI6::PlayerType::StudentPlayer;
student->props.clear(); student->props.clear();
for (int i = 0; i < studentMsg.prop().size(); i++)
for (int32_t i = 0; i < studentMsg.prop().size(); i++)
student->props.push_back(propTypeDict[studentMsg.prop(i)]); student->props.push_back(propTypeDict[studentMsg.prop(i)]);
// student->place = placeTypeDict[studentMsg.place()]; // student->place = placeTypeDict[studentMsg.place()];
student->playerState = playerStateDict[studentMsg.player_state()]; student->playerState = playerStateDict[studentMsg.player_state()];
@@ -276,7 +276,7 @@ namespace Proto2THUAI6
student->addiction = studentMsg.addiction(); student->addiction = studentMsg.addiction();
student->studentType = studentTypeDict[studentMsg.student_type()]; student->studentType = studentTypeDict[studentMsg.student_type()];
student->buff.clear(); student->buff.clear();
for (int i = 0; i < studentMsg.buff_size(); i++)
for (int32_t i = 0; i < studentMsg.buff_size(); i++)
student->buff.push_back(studentBuffTypeDict[studentMsg.buff(i)]); student->buff.push_back(studentBuffTypeDict[studentMsg.buff(i)]);
return student; return student;
} }


+ 4
- 4
CAPI/cpp/API/src/API.cpp View File

@@ -8,12 +8,12 @@


#define PI 3.14159265358979323846 #define PI 3.14159265358979323846


int StudentAPI::GetFrameCount() const
int32_t StudentAPI::GetFrameCount() const
{ {
return logic.GetCounter(); return logic.GetCounter();
} }


int TrickerAPI::GetFrameCount() const
int32_t TrickerAPI::GetFrameCount() const
{ {
return logic.GetCounter(); return logic.GetCounter();
} }
@@ -436,13 +436,13 @@ std::shared_ptr<const THUAI6::Tricker> TrickerAPI::GetSelfInfo() const
return logic.TrickerGetSelfInfo(); return logic.TrickerGetSelfInfo();
} }


bool StudentAPI::HaveView(int gridX, int gridY) const
bool StudentAPI::HaveView(int32_t gridX, int32_t gridY) const
{ {
auto selfInfo = GetSelfInfo(); auto selfInfo = GetSelfInfo();
return logic.HaveView(gridX, gridY, selfInfo->x, selfInfo->y, selfInfo->viewRange); return logic.HaveView(gridX, gridY, selfInfo->x, selfInfo->y, selfInfo->viewRange);
} }


bool TrickerAPI::HaveView(int gridX, int gridY) const
bool TrickerAPI::HaveView(int32_t gridX, int32_t gridY) const
{ {
auto selfInfo = GetSelfInfo(); auto selfInfo = GetSelfInfo();
return logic.HaveView(gridX, gridY, selfInfo->x, selfInfo->y, selfInfo->viewRange); return logic.HaveView(gridX, gridY, selfInfo->x, selfInfo->y, selfInfo->viewRange);


+ 4
- 4
CAPI/cpp/API/src/DebugAPI.cpp View File

@@ -82,12 +82,12 @@ void TrickerDebugAPI::EndTimer()
logger->info("Time elapsed: {}ms", Time::TimeSinceStart(startPoint)); logger->info("Time elapsed: {}ms", Time::TimeSinceStart(startPoint));
} }


int StudentDebugAPI::GetFrameCount() const
int32_t StudentDebugAPI::GetFrameCount() const
{ {
return logic.GetCounter(); return logic.GetCounter();
} }


int TrickerDebugAPI::GetFrameCount() const
int32_t TrickerDebugAPI::GetFrameCount() const
{ {
return logic.GetCounter(); return logic.GetCounter();
} }
@@ -656,13 +656,13 @@ std::shared_ptr<const THUAI6::Tricker> TrickerDebugAPI::GetSelfInfo() const
return logic.TrickerGetSelfInfo(); return logic.TrickerGetSelfInfo();
} }


bool StudentDebugAPI::HaveView(int gridX, int gridY) const
bool StudentDebugAPI::HaveView(int32_t gridX, int32_t gridY) const
{ {
auto selfInfo = GetSelfInfo(); auto selfInfo = GetSelfInfo();
return logic.HaveView(gridX, gridY, selfInfo->x, selfInfo->y, selfInfo->viewRange); return logic.HaveView(gridX, gridY, selfInfo->x, selfInfo->y, selfInfo->viewRange);
} }


bool TrickerDebugAPI::HaveView(int gridX, int gridY) const
bool TrickerDebugAPI::HaveView(int32_t gridX, int32_t gridY) const
{ {
auto selfInfo = GetSelfInfo(); auto selfInfo = GetSelfInfo();
return logic.HaveView(gridX, gridY, selfInfo->x, selfInfo->y, selfInfo->viewRange); return logic.HaveView(gridX, gridY, selfInfo->x, selfInfo->y, selfInfo->viewRange);


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

@@ -335,10 +335,10 @@ void Logic::ProcessMessage()
{ {
auto map = std::vector<std::vector<THUAI6::PlaceType>>(); auto map = std::vector<std::vector<THUAI6::PlaceType>>();
auto mapResult = item.map_message(); auto mapResult = item.map_message();
for (int i = 0; i < item.map_message().row_size(); i++)
for (int32_t i = 0; i < item.map_message().row_size(); i++)
{ {
std::vector<THUAI6::PlaceType> row; std::vector<THUAI6::PlaceType> row;
for (int j = 0; j < mapResult.row(i).col_size(); j++)
for (int32_t j = 0; j < mapResult.row(i).col_size(); j++)
{ {
if (Proto2THUAI6::placeTypeDict.count(mapResult.row(i).col(j)) == 0) if (Proto2THUAI6::placeTypeDict.count(mapResult.row(i).col(j)) == 0)
logger->error("Unknown place type!"); logger->error("Unknown place type!");
@@ -438,7 +438,7 @@ void Logic::LoadBufferCase(const protobuf::MessageOfObj& item)


if (playerType == THUAI6::PlayerType::StudentPlayer && Proto2THUAI6::messageOfObjDict[item.message_of_obj_case()] == THUAI6::MessageOfObj::TrickerMessage) if (playerType == THUAI6::PlayerType::StudentPlayer && Proto2THUAI6::messageOfObjDict[item.message_of_obj_case()] == THUAI6::MessageOfObj::TrickerMessage)
{ {
for (int i = 0; i < item.tricker_message().buff_size(); i++)
for (int32_t i = 0; i < item.tricker_message().buff_size(); i++)
if (Proto2THUAI6::trickerBuffTypeDict[item.tricker_message().buff(i)] == THUAI6::TrickerBuffType::Invisible) if (Proto2THUAI6::trickerBuffTypeDict[item.tricker_message().buff(i)] == THUAI6::TrickerBuffType::Invisible)
return; return;
if (AssistFunction::HaveView(viewRange, x, y, item.tricker_message().x(), item.tricker_message().y(), bufferState->gameMap)) if (AssistFunction::HaveView(viewRange, x, y, item.tricker_message().x(), item.tricker_message().y(), bufferState->gameMap))
@@ -457,7 +457,7 @@ void Logic::LoadBufferCase(const protobuf::MessageOfObj& item)
logger->debug("Add Student!"); logger->debug("Add Student!");
return; return;
} }
for (int i = 0; i < item.student_message().buff_size(); i++)
for (int32_t i = 0; i < item.student_message().buff_size(); i++)
if (Proto2THUAI6::studentBuffTypeDict[item.student_message().buff(i)] == THUAI6::StudentBuffType::Invisible) if (Proto2THUAI6::studentBuffTypeDict[item.student_message().buff(i)] == THUAI6::StudentBuffType::Invisible)
return; return;
if (AssistFunction::HaveView(viewRange, x, y, item.student_message().x(), item.student_message().y(), bufferState->gameMap)) if (AssistFunction::HaveView(viewRange, x, y, item.student_message().x(), item.student_message().y(), bufferState->gameMap))
@@ -685,7 +685,7 @@ void Logic::UnBlockAI()
cvAI.notify_one(); cvAI.notify_one();
} }


int Logic::GetCounter() const
int32_t Logic::GetCounter() const
{ {
std::unique_lock<std::mutex> lock(mtxState); std::unique_lock<std::mutex> lock(mtxState);
return counterState; return counterState;
@@ -703,7 +703,7 @@ bool Logic::TryConnection()
return pComm->TryConnection(playerID); return pComm->TryConnection(playerID);
} }


bool Logic::HaveView(int gridX, int gridY, int selfX, int selfY, int viewRange) const
bool Logic::HaveView(int32_t gridX, int32_t gridY, int32_t selfX, int32_t selfY, int32_t viewRange) const
{ {
std::unique_lock<std::mutex> lock(mtxState); std::unique_lock<std::mutex> lock(mtxState);
return AssistFunction::HaveView(viewRange, selfX, selfY, gridX, gridY, currentState->gameMap); return AssistFunction::HaveView(viewRange, selfX, selfY, gridX, gridY, currentState->gameMap);


Loading…
Cancel
Save