|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459 |
- #include <optional>
- #include "AI.h"
- #include "API.h"
-
- #undef GetMessage
- #undef SendMessage
- #undef PeekMessage
-
- #define PI 3.14159265358979323846
-
- int StudentAPI::GetFrameCount() const
- {
- return logic.GetCounter();
- }
-
- int TrickerAPI::GetFrameCount() const
- {
- return logic.GetCounter();
- }
-
- std::future<bool> StudentAPI::Move(int64_t timeInMilliseconds, double angleInRadian)
- {
- return std::async(std::launch::async, [=]()
- { return logic.Move(timeInMilliseconds, angleInRadian); });
- }
-
- std::future<bool> StudentAPI::MoveDown(int64_t timeInMilliseconds)
- {
- return Move(timeInMilliseconds, 0);
- }
-
- std::future<bool> StudentAPI::MoveRight(int64_t timeInMilliseconds)
- {
- return Move(timeInMilliseconds, PI * 0.5);
- }
-
- std::future<bool> StudentAPI::MoveUp(int64_t timeInMilliseconds)
- {
- return Move(timeInMilliseconds, PI);
- }
-
- std::future<bool> StudentAPI::MoveLeft(int64_t timeInMilliseconds)
- {
- return Move(timeInMilliseconds, PI * 1.5);
- }
-
- std::future<bool> TrickerAPI::Move(int64_t timeInMilliseconds, double angleInRadian)
- {
- return std::async(std::launch::async, [=]()
- { return logic.Move(timeInMilliseconds, angleInRadian); });
- }
-
- std::future<bool> TrickerAPI::MoveDown(int64_t timeInMilliseconds)
- {
- return Move(timeInMilliseconds, 0);
- }
-
- std::future<bool> TrickerAPI::MoveRight(int64_t timeInMilliseconds)
- {
- return Move(timeInMilliseconds, PI * 0.5);
- }
-
- std::future<bool> TrickerAPI::MoveUp(int64_t timeInMilliseconds)
- {
- return Move(timeInMilliseconds, PI);
- }
-
- std::future<bool> TrickerAPI::MoveLeft(int64_t timeInMilliseconds)
- {
- return Move(timeInMilliseconds, PI * 1.5);
- }
-
- std::future<bool> StudentAPI::PickProp(THUAI6::PropType prop)
- {
- return std::async(std::launch::async, [=]()
- { return logic.PickProp(prop); });
- }
-
- std::future<bool> StudentAPI::UseProp(THUAI6::PropType prop)
- {
- return std::async(std::launch::async, [=]()
- { return logic.UseProp(prop); });
- }
-
- std::future<bool> TrickerAPI::PickProp(THUAI6::PropType prop)
- {
- return std::async(std::launch::async, [=]()
- { return logic.PickProp(prop); });
- }
-
- std::future<bool> TrickerAPI::UseProp(THUAI6::PropType prop)
- {
- return std::async(std::launch::async, [=]()
- { return logic.UseProp(prop); });
- }
-
- std::future<bool> StudentAPI::ThrowProp(THUAI6::PropType prop)
- {
- return std::async(std::launch::async, [=]()
- { return logic.ThrowProp(prop); });
- }
-
- std::future<bool> TrickerAPI::ThrowProp(THUAI6::PropType prop)
- {
- return std::async(std::launch::async, [=]()
- { return logic.ThrowProp(prop); });
- }
-
- std::future<bool> StudentAPI::UseSkill(int32_t skillID, int32_t skillParam)
- {
- return std::async(std::launch::async, [=]()
- { return logic.UseSkill(skillID, skillParam); });
- }
-
- std::future<bool> TrickerAPI::UseSkill(int32_t skillID, int32_t skillParam)
- {
- return std::async(std::launch::async, [=]()
- { return logic.UseSkill(skillID, skillParam); });
- }
-
- std::future<bool> StudentAPI::OpenDoor()
- {
- return std::async(std::launch::async, [this]()
- { return logic.OpenDoor(); });
- }
-
- std::future<bool> TrickerAPI::OpenDoor()
- {
- return std::async(std::launch::async, [this]()
- { return logic.OpenDoor(); });
- }
-
- std::future<bool> StudentAPI::CloseDoor()
- {
- return std::async(std::launch::async, [this]()
- { return logic.CloseDoor(); });
- }
-
- std::future<bool> TrickerAPI::CloseDoor()
- {
- return std::async(std::launch::async, [this]()
- { return logic.CloseDoor(); });
- }
-
- std::future<bool> StudentAPI::SkipWindow()
- {
- return std::async(std::launch::async, [this]()
- { return logic.SkipWindow(); });
- }
-
- std::future<bool> TrickerAPI::SkipWindow()
- {
- return std::async(std::launch::async, [this]()
- { return logic.SkipWindow(); });
- }
-
- std::future<bool> StudentAPI::StartOpenGate()
- {
- return std::async(std::launch::async, [this]()
- { return logic.StartOpenGate(); });
- }
-
- std::future<bool> TrickerAPI::StartOpenGate()
- {
- return std::async(std::launch::async, [this]()
- { return logic.StartOpenGate(); });
- }
-
- std::future<bool> StudentAPI::StartOpenChest()
- {
- return std::async(std::launch::async, [this]()
- { return logic.StartOpenChest(); });
- }
-
- std::future<bool> TrickerAPI::StartOpenChest()
- {
- return std::async(std::launch::async, [this]()
- { return logic.StartOpenChest(); });
- }
-
- std::future<bool> StudentAPI::EndAllAction()
- {
- return std::async(std::launch::async, [this]()
- { return logic.EndAllAction(); });
- }
-
- std::future<bool> TrickerAPI::EndAllAction()
- {
- return std::async(std::launch::async, [this]()
- { return logic.EndAllAction(); });
- }
-
- std::future<bool> StudentAPI::SendTextMessage(int64_t toID, std::string message)
- {
- return std::async(std::launch::async, [=]()
- { return logic.SendMessage(toID, message, false); });
- }
-
- std::future<bool> TrickerAPI::SendTextMessage(int64_t toID, std::string message)
- {
- return std::async(std::launch::async, [=]()
- { return logic.SendMessage(toID, message, false); });
- }
-
- std::future<bool> StudentAPI::SendBinaryMessage(int64_t toID, std::string message)
- {
- return std::async(std::launch::async, [=]()
- { return logic.SendMessage(toID, message, false); });
- }
-
- std::future<bool> TrickerAPI::SendBinaryMessage(int64_t toID, std::string message)
- {
- return std::async(std::launch::async, [=]()
- { return logic.SendMessage(toID, message, false); });
- }
-
- bool StudentAPI::HaveMessage()
- {
- return logic.HaveMessage();
- }
-
- bool TrickerAPI::HaveMessage()
- {
- return logic.HaveMessage();
- }
-
- std::pair<int64_t, std::string> StudentAPI::GetMessage()
- {
- return logic.GetMessage();
- }
-
- std::pair<int64_t, std::string> TrickerAPI::GetMessage()
- {
- return logic.GetMessage();
- }
-
- bool StudentAPI::Wait()
- {
- if (logic.GetCounter() == -1)
- return false;
- else
- return logic.WaitThread();
- }
-
- bool TrickerAPI::Wait()
- {
- if (logic.GetCounter() == -1)
- return false;
- else
- return logic.WaitThread();
- }
-
- std::vector<std::shared_ptr<const THUAI6::Tricker>> StudentAPI::GetTrickers() const
- {
- return logic.GetTrickers();
- }
-
- std::vector<std::shared_ptr<const THUAI6::Student>> StudentAPI::GetStudents() const
- {
- return logic.GetStudents();
- }
-
- std::vector<std::shared_ptr<const THUAI6::Tricker>> TrickerAPI::GetTrickers() const
- {
- return logic.GetTrickers();
- }
-
- std::vector<std::shared_ptr<const THUAI6::Student>> TrickerAPI::GetStudents() const
- {
- return logic.GetStudents();
- }
-
- std::vector<std::shared_ptr<const THUAI6::Prop>> StudentAPI::GetProps() const
- {
- return logic.GetProps();
- }
-
- std::vector<std::shared_ptr<const THUAI6::Prop>> TrickerAPI::GetProps() const
- {
- return logic.GetProps();
- }
-
- std::vector<std::shared_ptr<const THUAI6::Bullet>> StudentAPI::GetBullets() const
- {
- return logic.GetBullets();
- }
-
- std::vector<std::shared_ptr<const THUAI6::Bullet>> TrickerAPI::GetBullets() const
- {
- return logic.GetBullets();
- }
-
- std::vector<std::vector<THUAI6::PlaceType>> StudentAPI::GetFullMap() const
- {
- return logic.GetFullMap();
- }
-
- THUAI6::PlaceType StudentAPI::GetPlaceType(int32_t cellX, int32_t cellY) const
- {
- return logic.GetPlaceType(cellX, cellY);
- }
-
- THUAI6::PlaceType TrickerAPI::GetPlaceType(int32_t cellX, int32_t cellY) const
- {
- return logic.GetPlaceType(cellX, cellY);
- }
-
- std::vector<std::vector<THUAI6::PlaceType>> TrickerAPI::GetFullMap() const
- {
- return logic.GetFullMap();
- }
-
- bool StudentAPI::IsDoorOpen(int32_t cellX, int32_t cellY) const
- {
- return logic.IsDoorOpen(cellX, cellY);
- }
-
- bool TrickerAPI::IsDoorOpen(int32_t cellX, int32_t cellY) const
- {
- return logic.IsDoorOpen(cellX, cellY);
- }
-
- int32_t StudentAPI::GetClassroomProgress(int32_t cellX, int32_t cellY) const
- {
- return logic.GetClassroomProgress(cellX, cellY);
- }
-
- int32_t TrickerAPI::GetClassroomProgress(int32_t cellX, int32_t cellY) const
- {
- return logic.GetClassroomProgress(cellX, cellY);
- }
-
- int32_t StudentAPI::GetChestProgress(int32_t cellX, int32_t cellY) const
- {
- return logic.GetChestProgress(cellX, cellY);
- }
-
- int32_t TrickerAPI::GetChestProgress(int32_t cellX, int32_t cellY) const
- {
- return logic.GetChestProgress(cellX, cellY);
- }
-
- int32_t StudentAPI::GetGateProgress(int32_t cellX, int32_t cellY) const
- {
- return logic.GetGateProgress(cellX, cellY);
- }
-
- int32_t TrickerAPI::GetGateProgress(int32_t cellX, int32_t cellY) const
- {
- return logic.GetGateProgress(cellX, cellY);
- }
-
- int32_t StudentAPI::GetDoorProgress(int32_t cellX, int32_t cellY) const
- {
- return logic.GetDoorProgress(cellX, cellY);
- }
-
- int32_t TrickerAPI::GetDoorProgress(int32_t cellX, int32_t cellY) const
- {
- return logic.GetDoorProgress(cellX, cellY);
- }
-
- THUAI6::HiddenGateState StudentAPI::GetHiddenGateState(int32_t cellX, int32_t cellY) const
- {
- return logic.GetHiddenGateState(cellX, cellY);
- }
-
- THUAI6::HiddenGateState TrickerAPI::GetHiddenGateState(int32_t cellX, int32_t cellY) const
- {
- return logic.GetHiddenGateState(cellX, cellY);
- }
-
- std::shared_ptr<const THUAI6::GameInfo> StudentAPI::GetGameInfo() const
- {
- return logic.GetGameInfo();
- }
-
- std::shared_ptr<const THUAI6::GameInfo> TrickerAPI::GetGameInfo() const
- {
- return logic.GetGameInfo();
- }
-
- std::vector<int64_t> StudentAPI::GetPlayerGUIDs() const
- {
- return logic.GetPlayerGUIDs();
- }
-
- std::vector<int64_t> TrickerAPI::GetPlayerGUIDs() const
- {
- return logic.GetPlayerGUIDs();
- }
-
- std::future<bool> StudentAPI::StartLearning()
- {
- return std::async(std::launch::async, [this]()
- { return logic.StartLearning(); });
- }
-
- std::future<bool> StudentAPI::StartEncourageMate(int64_t mateID)
- {
- return std::async(std::launch::async, [=]()
- { return logic.StartEncourageMate(mateID); });
- }
-
- std::future<bool> StudentAPI::StartRouseMate(int64_t mateID)
- {
- return std::async(std::launch::async, [=]()
- { return logic.StartRouseMate(mateID); });
- }
-
- std::future<bool> StudentAPI::Graduate()
- {
- return std::async(std::launch::async, [this]()
- { return logic.Graduate(); });
- }
-
- std::shared_ptr<const THUAI6::Student> StudentAPI::GetSelfInfo() const
- {
- return logic.StudentGetSelfInfo();
- }
-
- std::future<bool> TrickerAPI::Attack(double angleInRadian)
- {
- return std::async(std::launch::async, [=]()
- { return logic.Attack(angleInRadian); });
- }
-
- std::future<bool> StudentAPI::Attack(double angleInRadian)
- {
- return std::async(std::launch::async, [=]()
- { return logic.Attack(angleInRadian); });
- }
-
- std::shared_ptr<const THUAI6::Tricker> TrickerAPI::GetSelfInfo() const
- {
- return logic.TrickerGetSelfInfo();
- }
-
- bool StudentAPI::HaveView(int gridX, int gridY) const
- {
- auto selfInfo = GetSelfInfo();
- return logic.HaveView(gridX, gridY, selfInfo->x, selfInfo->y, selfInfo->viewRange);
- }
-
- bool TrickerAPI::HaveView(int gridX, int gridY) const
- {
- auto selfInfo = GetSelfInfo();
- return logic.HaveView(gridX, gridY, selfInfo->x, selfInfo->y, selfInfo->viewRange);
- }
-
- void StudentAPI::Play(IAI& ai)
- {
- ai.play(*this);
- }
-
- void TrickerAPI::Play(IAI& ai)
- {
- ai.play(*this);
- }
|