Skip to content

Commit

Permalink
Merge branch 'dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
shangfengh authored Mar 12, 2024
2 parents 0e65714 + d29693c commit 773dce8
Show file tree
Hide file tree
Showing 36 changed files with 2,703 additions and 2,837 deletions.
4 changes: 2 additions & 2 deletions CAPI/cpp/API/include/AI.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class IAI
public:
virtual ~IAI() = default;
IAI() = default;
virtual void play(IShipAPI& api) = 0;
virtual void play(ISweeperAPI& api) = 0;
virtual void play(ITeamAPI& api) = 0;
};

Expand All @@ -27,7 +27,7 @@ class AI : public IAI
playerID(pID)
{
}
void play(IShipAPI& api) override;
void play(ISweeperAPI& api) override;
void play(ITeamAPI& api) override;

private:
Expand Down
98 changes: 49 additions & 49 deletions CAPI/cpp/API/include/API.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,20 @@ class ILogic

public:
// 获取服务器发来的消息
[[nodiscard]] virtual std::vector<std::shared_ptr<const THUAI7::Ship>> GetShips() const = 0;
[[nodiscard]] virtual std::vector<std::shared_ptr<const THUAI7::Ship>> GetEnemyShips() const = 0;
[[nodiscard]] virtual std::vector<std::shared_ptr<const THUAI7::Sweeper>> GetSweepers() const = 0;
[[nodiscard]] virtual std::vector<std::shared_ptr<const THUAI7::Sweeper>> GetEnemySweepers() const = 0;
[[nodiscard]] virtual std::vector<std::shared_ptr<const THUAI7::Bullet>> GetBullets() const = 0;
[[nodiscard]] virtual std::shared_ptr<const THUAI7::Ship> ShipGetSelfInfo() const = 0;
[[nodiscard]] virtual std::shared_ptr<const THUAI7::Sweeper> SweeperGetSelfInfo() const = 0;
[[nodiscard]] virtual std::shared_ptr<const THUAI7::Team> TeamGetSelfInfo() const = 0;
[[nodiscard]] virtual std::vector<std::vector<THUAI7::PlaceType>> GetFullMap() const = 0;
[[nodiscard]] virtual std::shared_ptr<const THUAI7::GameInfo> GetGameInfo() const = 0;
[[nodiscard]] virtual std::vector<int64_t> GetPlayerGUIDs() const = 0;
[[nodiscard]] virtual THUAI7::PlaceType GetPlaceType(int32_t cellX, int32_t cellY) const = 0;
[[nodiscard]] virtual int32_t GetConstructionHp(int32_t cellX, int32_t cellY) const = 0;
[[nodiscard]] virtual int32_t GetWormHp(int32_t cellX, int32_t cellY) const = 0;
[[nodiscard]] virtual int32_t GetResourceState(int32_t cellX, int32_t cellY) const = 0;
[[nodiscard]] virtual int32_t GetBridgeHp(int32_t cellX, int32_t cellY) const = 0;
[[nodiscard]] virtual int32_t GetGarbageState(int32_t cellX, int32_t cellY) const = 0;
[[nodiscard]] virtual int32_t GetHomeHp() const = 0;
[[nodiscard]] virtual int32_t GetMoney() const = 0;
[[nodiscard]] virtual int32_t GetEnergy() const = 0;
[[nodiscard]] virtual int32_t GetScore() const = 0;

// 供IAPI使用的操作相关的公共部分
Expand All @@ -60,7 +60,7 @@ class ILogic
virtual int32_t GetCounter() const = 0;
virtual bool EndAllAction() = 0;

// IShipAPI使用的部分
// ISweeperAPI使用的部分
virtual bool Move(int64_t time, double angle) = 0;
virtual bool Recover() = 0;
virtual bool Produce() = 0;
Expand All @@ -72,7 +72,7 @@ class ILogic
// Team使用的部分
virtual bool Recycle(int64_t playerID) = 0;
virtual bool InstallModule(int64_t playerID, THUAI7::ModuleType moduleType) = 0;
virtual bool BuildShip(THUAI7::ShipType shipType, int32_t cellX, int32_t cellY) = 0;
virtual bool BuildSweeper(THUAI7::SweeperType SweeperType, int32_t cellX, int32_t cellY) = 0;
};

class IAPI
Expand All @@ -91,17 +91,17 @@ class IAPI
// 等待下一帧
virtual bool Wait() = 0;
virtual std::future<bool> EndAllAction() = 0;
[[nodiscard]] virtual std::vector<std::shared_ptr<const THUAI7::Ship>> GetShips() const = 0;
[[nodiscard]] virtual std::vector<std::shared_ptr<const THUAI7::Ship>> GetEnemyShips() const = 0;
[[nodiscard]] virtual std::vector<std::shared_ptr<const THUAI7::Sweeper>> GetSweepers() const = 0;
[[nodiscard]] virtual std::vector<std::shared_ptr<const THUAI7::Sweeper>> GetEnemySweepers() const = 0;
[[nodiscard]] virtual std::vector<std::shared_ptr<const THUAI7::Bullet>> GetBullets() const = 0;
[[nodiscard]] virtual std::vector<std::vector<THUAI7::PlaceType>> GetFullMap() const = 0;
[[nodiscard]] virtual std::shared_ptr<const THUAI7::GameInfo> GetGameInfo() const = 0;
[[nodiscard]] virtual THUAI7::PlaceType GetPlaceType(int32_t cellX, int32_t cellY) const = 0;
[[nodiscard]] virtual int32_t GetConstructionHp(int32_t cellX, int32_t cellY) const = 0;
[[nodiscard]] virtual int32_t GetWormHp(int32_t cellX, int32_t cellY) const = 0;
[[nodiscard]] virtual int32_t GetResourceState(int32_t cellX, int32_t cellY) const = 0;
[[nodiscard]] virtual int32_t GetBridgeHp(int32_t cellX, int32_t cellY) const = 0;
[[nodiscard]] virtual int32_t GetGarbageState(int32_t cellX, int32_t cellY) const = 0;
[[nodiscard]] virtual int32_t GetHomeHp() const = 0;
[[nodiscard]] virtual int32_t GetMoney() const = 0;
[[nodiscard]] virtual int32_t GetEnergy() const = 0;
[[nodiscard]] virtual int32_t GetScore() const = 0;
[[nodiscard]] virtual std::vector<int64_t> GetPlayerGUIDs() const = 0;

Expand All @@ -122,12 +122,12 @@ class IAPI
// 用于DEBUG的输出函数,选手仅在开启Debug模式的情况下可以使用

virtual void Print(std::string str) const = 0;
virtual void PrintShip() const = 0;
virtual void PrintSweeper() const = 0;
virtual void PrintTeam() const = 0;
virtual void PrintSelfInfo() const = 0;
};

class IShipAPI : public IAPI
class ISweeperAPI : public IAPI
{
public:
virtual std::future<bool> Move(int64_t timeInMilliseconds, double angleInRadian) = 0;
Expand All @@ -141,7 +141,7 @@ class IShipAPI : public IAPI
virtual std::future<bool> Produce() = 0;
virtual std::future<bool> Rebuild(THUAI7::ConstructionType constructionType) = 0;
virtual std::future<bool> Construct(THUAI7::ConstructionType constructionType) = 0;
virtual std::shared_ptr<const THUAI7::Ship> GetSelfInfo() const = 0;
virtual std::shared_ptr<const THUAI7::Sweeper> GetSelfInfo() const = 0;
virtual bool HaveView(int32_t gridX, int32_t gridY) const = 0;
};

Expand All @@ -151,7 +151,7 @@ class ITeamAPI : public IAPI
[[nodiscard]] virtual std::shared_ptr<const THUAI7::Team> GetSelfInfo() const = 0;
virtual std::future<bool> InstallModule(int64_t playerID, THUAI7::ModuleType moduletype) = 0;
virtual std::future<bool> Recycle(int64_t playerID) = 0;
virtual std::future<bool> BuildShip(THUAI7::ShipType shipType, int32_t cellX, int32_t cellY) = 0;
virtual std::future<bool> BuildSweeper(THUAI7::SweeperType SweeperType, int32_t cellX, int32_t cellY) = 0;
};

class IGameTimer
Expand All @@ -163,10 +163,10 @@ class IGameTimer
virtual void Play(IAI& ai) = 0;
};

class ShipAPI : public IShipAPI, public IGameTimer
class SweeperAPI : public ISweeperAPI, public IGameTimer
{
public:
ShipAPI(ILogic& logic) :
SweeperAPI(ILogic& logic) :
logic(logic)
{
}
Expand Down Expand Up @@ -198,25 +198,25 @@ class ShipAPI : public IShipAPI, public IGameTimer
std::future<bool> Rebuild(THUAI7::ConstructionType constructionType) override;
std::future<bool> Construct(THUAI7::ConstructionType constructionType) override;

[[nodiscard]] std::vector<std::shared_ptr<const THUAI7::Ship>> GetShips() const override;
[[nodiscard]] std::vector<std::shared_ptr<const THUAI7::Ship>> GetEnemyShips() const override;
[[nodiscard]] std::vector<std::shared_ptr<const THUAI7::Sweeper>> GetSweepers() const override;
[[nodiscard]] std::vector<std::shared_ptr<const THUAI7::Sweeper>> GetEnemySweepers() const override;
[[nodiscard]] std::vector<std::shared_ptr<const THUAI7::Bullet>> GetBullets() const override;
[[nodiscard]] std::vector<std::vector<THUAI7::PlaceType>> GetFullMap() const override;
[[nodiscard]] THUAI7::PlaceType GetPlaceType(int32_t cellX, int32_t cellY) const override;
[[nodiscard]] int32_t GetConstructionHp(int32_t cellX, int32_t cellY) const override;
[[nodiscard]] int32_t GetWormHp(int32_t x, int32_t y) const override;
[[nodiscard]] int32_t GetResourceState(int32_t cellX, int32_t cellY) const override;
[[nodiscard]] int32_t GetBridgeHp(int32_t x, int32_t y) const override;
[[nodiscard]] int32_t GetGarbageState(int32_t cellX, int32_t cellY) const override;
[[nodiscard]] int32_t GetHomeHp() const override;
[[nodiscard]] std::shared_ptr<const THUAI7::GameInfo> GetGameInfo() const override;
[[nodiscard]] std::vector<int64_t> GetPlayerGUIDs() const override;
[[nodiscard]] std::shared_ptr<const THUAI7::Ship> GetSelfInfo() const override;
[[nodiscard]] std::shared_ptr<const THUAI7::Sweeper> GetSelfInfo() const override;
[[nodiscard]] bool HaveView(int32_t gridX, int32_t gridY) const override;
[[nodiscard]] int32_t GetMoney() const override;
[[nodiscard]] int32_t GetEnergy() const override;
[[nodiscard]] int32_t GetScore() const override;
void Print(std::string str) const
{
}
void PrintShip() const
void PrintSweeper() const
{
}
void PrintTeam() const
Expand Down Expand Up @@ -254,28 +254,28 @@ class TeamAPI : public ITeamAPI, public IGameTimer
bool Wait() override;
std::future<bool> EndAllAction() override;

[[nodiscard]] std::vector<std::shared_ptr<const THUAI7::Ship>> GetShips() const override;
[[nodiscard]] std::vector<std::shared_ptr<const THUAI7::Ship>> GetEnemyShips() const override;
[[nodiscard]] std::vector<std::shared_ptr<const THUAI7::Sweeper>> GetSweepers() const override;
[[nodiscard]] std::vector<std::shared_ptr<const THUAI7::Sweeper>> GetEnemySweepers() const override;
[[nodiscard]] std::vector<std::shared_ptr<const THUAI7::Bullet>> GetBullets() const override;
[[nodiscard]] std::vector<std::vector<THUAI7::PlaceType>> GetFullMap() const override;
[[nodiscard]] THUAI7::PlaceType GetPlaceType(int32_t cellX, int32_t cellY) const override;
[[nodiscard]] int32_t GetConstructionHp(int32_t cellX, int32_t cellY) const override;
[[nodiscard]] int32_t GetWormHp(int32_t x, int32_t y) const override;
[[nodiscard]] int32_t GetResourceState(int32_t cellX, int32_t cellY) const override;
[[nodiscard]] int32_t GetBridgeHp(int32_t x, int32_t y) const override;
[[nodiscard]] int32_t GetGarbageState(int32_t cellX, int32_t cellY) const override;
[[nodiscard]] int32_t GetHomeHp() const override;
[[nodiscard]] std::shared_ptr<const THUAI7::GameInfo> GetGameInfo() const override;
[[nodiscard]] std::vector<int64_t> GetPlayerGUIDs() const override;
[[nodiscard]] std::shared_ptr<const THUAI7::Team> GetSelfInfo() const override;

[[nodiscard]] int32_t GetScore() const override;
[[nodiscard]] int32_t GetMoney() const override;
[[nodiscard]] int32_t GetEnergy() const override;
std::future<bool> InstallModule(int64_t playerID, THUAI7::ModuleType moduleType) override;
std::future<bool> Recycle(int64_t playerID) override;
std::future<bool> BuildShip(THUAI7::ShipType shipType, int32_t cellX, int32_t cellY) override;
std::future<bool> BuildSweeper(THUAI7::SweeperType SweeperType, int32_t cellX, int32_t cellY) override;
void Print(std::string str) const
{
}
void PrintShip() const
void PrintSweeper() const
{
}
void PrintTeam() const
Expand All @@ -289,10 +289,10 @@ class TeamAPI : public ITeamAPI, public IGameTimer
ILogic& logic;
};

class ShipDebugAPI : public IShipAPI, public IGameTimer
class SweeperDebugAPI : public ISweeperAPI, public IGameTimer
{
public:
ShipDebugAPI(ILogic& logic, bool file, bool print, bool warnOnly, int64_t shipID);
SweeperDebugAPI(ILogic& logic, bool file, bool print, bool warnOnly, int64_t SweeperID);
void StartTimer() override;
void EndTimer() override;
void Play(IAI& ai) override;
Expand All @@ -315,24 +315,24 @@ class ShipDebugAPI : public IShipAPI, public IGameTimer
std::future<bool> Rebuild(THUAI7::ConstructionType constructionType) override;
std::future<bool> Construct(THUAI7::ConstructionType constructionType) override;

[[nodiscard]] std::vector<std::shared_ptr<const THUAI7::Ship>> GetShips() const override;
[[nodiscard]] std::vector<std::shared_ptr<const THUAI7::Ship>> GetEnemyShips() const override;
[[nodiscard]] std::vector<std::shared_ptr<const THUAI7::Sweeper>> GetSweepers() const override;
[[nodiscard]] std::vector<std::shared_ptr<const THUAI7::Sweeper>> GetEnemySweepers() const override;
[[nodiscard]] std::vector<std::shared_ptr<const THUAI7::Bullet>> GetBullets() const override;
[[nodiscard]] std::vector<std::vector<THUAI7::PlaceType>> GetFullMap() const override;
[[nodiscard]] THUAI7::PlaceType GetPlaceType(int32_t cellX, int32_t cellY) const override;
[[nodiscard]] int32_t GetConstructionHp(int32_t cellX, int32_t cellY) const override;
[[nodiscard]] int32_t GetWormHp(int32_t x, int32_t y) const override;
[[nodiscard]] int32_t GetResourceState(int32_t cellX, int32_t cellY) const override;
[[nodiscard]] int32_t GetBridgeHp(int32_t x, int32_t y) const override;
[[nodiscard]] int32_t GetGarbageState(int32_t cellX, int32_t cellY) const override;
[[nodiscard]] int32_t GetHomeHp() const override;
[[nodiscard]] std::shared_ptr<const THUAI7::GameInfo> GetGameInfo() const override;
[[nodiscard]] std::vector<int64_t> GetPlayerGUIDs() const override;
[[nodiscard]] std::shared_ptr<const THUAI7::Ship> GetSelfInfo() const override;
[[nodiscard]] std::shared_ptr<const THUAI7::Sweeper> GetSelfInfo() const override;
[[nodiscard]] bool HaveView(int32_t gridX, int32_t gridY) const override;
[[nodiscard]] int32_t GetMoney() const override;
[[nodiscard]] int32_t GetEnergy() const override;
[[nodiscard]] int32_t GetScore() const override;

void Print(std::string str) const override;
void PrintShip() const override;
void PrintSweeper() const override;
void PrintSelfInfo() const override;
void PrintTeam() const
{
Expand Down Expand Up @@ -361,31 +361,31 @@ class TeamDebugAPI : public ITeamAPI, public IGameTimer
bool Wait() override;
std::future<bool> EndAllAction() override;

[[nodiscard]] std::vector<std::shared_ptr<const THUAI7::Ship>> GetShips() const override;
[[nodiscard]] std::vector<std::shared_ptr<const THUAI7::Ship>> GetEnemyShips() const override;
[[nodiscard]] std::vector<std::shared_ptr<const THUAI7::Sweeper>> GetSweepers() const override;
[[nodiscard]] std::vector<std::shared_ptr<const THUAI7::Sweeper>> GetEnemySweepers() const override;
[[nodiscard]] std::vector<std::shared_ptr<const THUAI7::Bullet>> GetBullets() const override;
[[nodiscard]] std::vector<std::vector<THUAI7::PlaceType>> GetFullMap() const override;
[[nodiscard]] THUAI7::PlaceType GetPlaceType(int32_t cellX, int32_t cellY) const override;
[[nodiscard]] int32_t GetConstructionHp(int32_t cellX, int32_t cellY) const override;
[[nodiscard]] int32_t GetWormHp(int32_t x, int32_t y) const override;
[[nodiscard]] int32_t GetResourceState(int32_t cellX, int32_t cellY) const override;
[[nodiscard]] int32_t GetBridgeHp(int32_t x, int32_t y) const override;
[[nodiscard]] int32_t GetGarbageState(int32_t cellX, int32_t cellY) const override;
[[nodiscard]] int32_t GetHomeHp() const override;
[[nodiscard]] std::shared_ptr<const THUAI7::GameInfo> GetGameInfo() const override;
[[nodiscard]] std::vector<int64_t> GetPlayerGUIDs() const override;
[[nodiscard]] std::shared_ptr<const THUAI7::Team> GetSelfInfo() const override;

[[nodiscard]] int32_t GetScore() const override;
[[nodiscard]] int32_t GetMoney() const override;
[[nodiscard]] int32_t GetEnergy() const override;
std::future<bool> InstallModule(int64_t playerID, THUAI7::ModuleType moduleType) override;
std::future<bool> Recycle(int64_t playerID) override;
std::future<bool> BuildShip(THUAI7::ShipType shipType, int32_t cellX, int32_t cellY) override;
std::future<bool> BuildSweeper(THUAI7::SweeperType SweeperType, int32_t cellX, int32_t cellY) override;
void Print(std::string str) const override;
void PrintSelfInfo() const override;
// TODO
void PrintTeam() const
{
}
void PrintShip() const
void PrintSweeper() const
{
}

Expand Down
6 changes: 3 additions & 3 deletions CAPI/cpp/API/include/Communication.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ class Communication
}
bool TryConnection(int64_t playerID, int64_t teamID);
protobuf::MessageToClient GetMessage2Client();
void AddPlayer(int64_t playerID, int64_t teamID, THUAI7::ShipType shipType, int32_t x, int32_t y);
void AddPlayer(int64_t playerID, int64_t teamID, THUAI7::SweeperType SweeperType);
bool EndAllAction(int64_t playerID, int64_t teamID);
// Ship
// Sweeper
bool Move(int64_t playerID, int64_t teamID, int64_t time, double angle);
bool Recover(int64_t playerID, int64_t recover, int64_t teamID);
bool Produce(int64_t playerID, int64_t teamID);
Expand All @@ -41,7 +41,7 @@ class Communication
bool Send(int64_t playerID, int64_t toPlayerID, int64_t teamID, std::string message, bool binary);
// Team
bool InstallModule(int64_t playerID, int64_t teamID, THUAI7::ModuleType moduleType);
bool BuildShip(int64_t teamID, THUAI7::ShipType shipType, int32_t x, int32_t y);
bool BuildSweeper(int64_t teamID, THUAI7::SweeperType SweeperType, int32_t x, int32_t y);
bool Recycle(int64_t playerID, int64_t teamID);

private:
Expand Down
34 changes: 17 additions & 17 deletions CAPI/cpp/API/include/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,55 +14,55 @@ namespace Constants
{
SCCI int32_t frameDuration = 50; // 每帧毫秒数
// 地图相关
SCCI int32_t numOfGridPerCell = 1000; // 单位坐标数
SCCI int32_t rows = 50; // 地图行数
SCCI int32_t cols = 50; // 地图列数
SCCI int32_t maxResourceProgress = 200; // 大门最大进度
SCCI int32_t maxWormholeHp = 18000;
SCCI int32_t numOfGridPerCell = 1000; // 单位坐标数
SCCI int32_t rows = 50; // 地图行数
SCCI int32_t cols = 50; // 地图列数
SCCI int32_t maxGarbageProgress = 200;
SCCI int32_t maxBridgeHp = 18000;
SCCI double robPercent = 0.2; // 击杀获得经济比率
SCCI int32_t DestroyBuildingBonus = 200;
SCCI double recoverMultiplier = 1.2;
SCCI double recycleMultiplier = 0.5;
struct Home
{
SCCI int32_t maxHp = 24000;
SCCI int32_t moneySpeed = 1;
SCCI int32_t energySpeed = 1;
};
struct Factory
struct RecycleBank
{
SCCI int32_t maxHp = 8000;
SCCI int32_t moneySpeed = 3;
SCCI int32_t energySpeed = 3;
};
struct Community
struct ChargeStation
{
SCCI int32_t maxHp = 6000;
};
struct Fort
struct SignalTower
{
SCCI int32_t maxHp = 12000;
SCCI int32_t attackRange = 8000;
SCCI int32_t damage = 1200;
};

//
SCCI int32_t sizeofShip = 800;
struct CivilianShip
SCCI int32_t sizeofSweeper = 800;
struct CivilianSweeper
{
SCCI int32_t maxHp = 3000;
SCCI int32_t basicArmor = 0;
SCCI int32_t basicShield = 0;
SCCI int32_t Speed = 3000;
SCCI int32_t Cost = 40;
};
struct MilitaryShip
struct MilitarySweeper
{
SCCI int32_t maxHp = 4000;
SCCI int32_t basicArmor = 400;
SCCI int32_t basicShield = 400;
SCCI int32_t Speed = 2800;
SCCI int32_t Cost = 120;
};
struct FlagShip
struct FlagSweeper
{
SCCI int32_t maxHp = 12000;
SCCI int32_t basicArmor = 800;
Expand All @@ -74,9 +74,9 @@ namespace Constants
// 模块
struct Producer
{
SCCI int32_t moneySpeed1 = 5;
SCCI int32_t moneySpeed2 = 7;
SCCI int32_t moneySpeed3 = 10;
SCCI int32_t energySpeed1 = 5;
SCCI int32_t energySpeed2 = 7;
SCCI int32_t energySpeed3 = 10;
SCCI int32_t Cost1 = 0;
SCCI int32_t Cost2 = 40;
SCCI int32_t Cost3 = 80;
Expand Down
Loading

0 comments on commit 773dce8

Please sign in to comment.