|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292 |
- #include <optional>
- #include "AI.h"
- #include "API.h"
- #define PI 3.14159265358979323846
-
- int HumanAPI::GetFrameCount() const
- {
- return logic.GetCounter();
- }
-
- int ButcherAPI::GetFrameCount() const
- {
- return logic.GetCounter();
- }
-
- std::future<bool> HumanAPI::Move(int64_t timeInMilliseconds, double angleInRadian)
- {
- return std::async(std::launch::async, [&]()
- { return logic.Move(timeInMilliseconds, angleInRadian); });
- }
-
- std::future<bool> HumanAPI::MoveDown(int64_t timeInMilliseconds)
- {
- return Move(timeInMilliseconds, 0);
- }
-
- std::future<bool> HumanAPI::MoveRight(int64_t timeInMilliseconds)
- {
- return Move(timeInMilliseconds, PI * 0.5);
- }
-
- std::future<bool> HumanAPI::MoveUp(int64_t timeInMilliseconds)
- {
- return Move(timeInMilliseconds, PI);
- }
-
- std::future<bool> HumanAPI::MoveLeft(int64_t timeInMilliseconds)
- {
- return Move(timeInMilliseconds, PI * 1.5);
- }
-
- std::future<bool> ButcherAPI::Move(int64_t timeInMilliseconds, double angleInRadian)
- {
- return std::async(std::launch::async, [&]()
- { return logic.Move(timeInMilliseconds, angleInRadian); });
- }
-
- std::future<bool> ButcherAPI::MoveDown(int64_t timeInMilliseconds)
- {
- return Move(timeInMilliseconds, 0);
- }
-
- std::future<bool> ButcherAPI::MoveRight(int64_t timeInMilliseconds)
- {
- return Move(timeInMilliseconds, PI * 0.5);
- }
-
- std::future<bool> ButcherAPI::MoveUp(int64_t timeInMilliseconds)
- {
- return Move(timeInMilliseconds, PI);
- }
-
- std::future<bool> ButcherAPI::MoveLeft(int64_t timeInMilliseconds)
- {
- return Move(timeInMilliseconds, PI * 1.5);
- }
-
- std::future<bool> HumanAPI::PickProp(THUAI6::PropType prop)
- {
- return std::async(std::launch::async, [&]()
- { return logic.PickProp(prop); });
- }
-
- std::future<bool> HumanAPI::UseProp()
- {
- return std::async(std::launch::async, [&]()
- { return logic.UseProp(); });
- }
-
- std::future<bool> ButcherAPI::PickProp(THUAI6::PropType prop)
- {
- return std::async(std::launch::async, [&]()
- { return logic.PickProp(prop); });
- }
-
- std::future<bool> ButcherAPI::UseProp()
- {
- return std::async(std::launch::async, [&]()
- { return logic.UseProp(); });
- }
-
- std::future<bool> HumanAPI::UseSkill()
- {
- return std::async(std::launch::async, [&]()
- { return logic.UseSkill(); });
- }
-
- std::future<bool> ButcherAPI::UseSkill()
- {
- return std::async(std::launch::async, [&]()
- { return logic.UseSkill(); });
- }
-
- std::future<bool> HumanAPI::SendMessage(int64_t toID, std::string message)
- {
- return std::async(std::launch::async, [&]()
- { return logic.SendMessage(toID, message); });
- }
-
- std::future<bool> ButcherAPI::SendMessage(int64_t toID, std::string message)
- {
- return std::async(std::launch::async, [&]()
- { return logic.SendMessage(toID, message); });
- }
-
- std::future<bool> HumanAPI::HaveMessage()
- {
- return std::async(std::launch::async, [&]()
- { return logic.HaveMessage(); });
- }
-
- std::future<bool> ButcherAPI::HaveMessage()
- {
- return std::async(std::launch::async, [&]()
- { return logic.HaveMessage(); });
- }
-
- std::future<std::optional<std::pair<int64_t, std::string>>> HumanAPI::GetMessage()
- {
- return std::async(std::launch::async, [&]()
- { return logic.GetMessage(); });
- }
-
- std::future<std::optional<std::pair<int64_t, std::string>>> ButcherAPI::GetMessage()
- {
- return std::async(std::launch::async, [&]()
- { return logic.GetMessage(); });
- }
-
- std::future<bool> HumanAPI::Wait()
- {
- if (logic.GetCounter() == -1)
- return std::async(std::launch::async, [&]()
- { return false; });
- else
- return std::async(std::launch::async, [&]()
- { return logic.WaitThread(); });
- }
-
- std::future<bool> ButcherAPI::Wait()
- {
- if (logic.GetCounter() == -1)
- return std::async(std::launch::async, [&]()
- { return false; });
- else
- return std::async(std::launch::async, [&]()
- { return logic.WaitThread(); });
- }
-
- std::vector<std::shared_ptr<const THUAI6::Butcher>> HumanAPI::GetButchers() const
- {
- return logic.GetButchers();
- }
-
- std::vector<std::shared_ptr<const THUAI6::Human>> HumanAPI::GetHumans() const
- {
- return logic.GetHumans();
- }
-
- std::vector<std::shared_ptr<const THUAI6::Butcher>> ButcherAPI::GetButchers() const
- {
- return logic.GetButchers();
- }
-
- std::vector<std::shared_ptr<const THUAI6::Human>> ButcherAPI::GetHumans() const
- {
- return logic.GetHumans();
- }
-
- std::vector<std::shared_ptr<const THUAI6::Prop>> HumanAPI::GetProps() const
- {
- return logic.GetProps();
- }
-
- std::vector<std::shared_ptr<const THUAI6::Prop>> ButcherAPI::GetProps() const
- {
- return logic.GetProps();
- }
-
- std::vector<std::vector<THUAI6::PlaceType>> HumanAPI::GetFullMap() const
- {
- return logic.GetFullMap();
- }
-
- THUAI6::PlaceType HumanAPI::GetPlaceType(int32_t cellX, int32_t cellY) const
- {
- return logic.GetPlaceType(cellX, cellY);
- }
-
- THUAI6::PlaceType ButcherAPI::GetPlaceType(int32_t cellX, int32_t cellY) const
- {
- return logic.GetPlaceType(cellX, cellY);
- }
-
- std::vector<std::vector<THUAI6::PlaceType>> ButcherAPI::GetFullMap() const
- {
- return logic.GetFullMap();
- }
-
- const std::vector<int64_t> HumanAPI::GetPlayerGUIDs() const
- {
- return logic.GetPlayerGUIDs();
- }
-
- const std::vector<int64_t> ButcherAPI::GetPlayerGUIDs() const
- {
- return logic.GetPlayerGUIDs();
- }
-
- std::future<bool> HumanAPI::StartFixMachine()
- {
- return std::async(std::launch::async, [&]()
- { return logic.StartFixMachine(); });
- }
-
- std::future<bool> HumanAPI::EndFixMachine()
- {
- return std::async(std::launch::async, [&]()
- { return logic.EndFixMachine(); });
- }
-
- std::future<bool> HumanAPI::StartSaveHuman()
- {
- return std::async(std::launch::async, [&]()
- { return logic.StartSaveHuman(); });
- }
-
- std::future<bool> HumanAPI::EndSaveHuman()
- {
- return std::async(std::launch::async, [&]()
- { return logic.EndSaveHuman(); });
- }
-
- std::future<bool> HumanAPI::Escape()
- {
- return std::async(std::launch::async, [&]()
- { return logic.Escape(); });
- }
-
- std::shared_ptr<const THUAI6::Human> HumanAPI::GetSelfInfo() const
- {
- return logic.HumanGetSelfInfo();
- }
-
- std::future<bool> ButcherAPI::Attack(double angleInRadian)
- {
- return std::async(std::launch::async, [&]()
- { return logic.Attack(angleInRadian); });
- }
-
- std::future<bool> ButcherAPI::CarryHuman()
- {
- return std::async(std::launch::async, [&]()
- { return logic.CarryHuman(); });
- }
-
- std::future<bool> ButcherAPI::ReleaseHuman()
- {
- return std::async(std::launch::async, [&]()
- { return logic.ReleaseHuman(); });
- }
-
- std::future<bool> ButcherAPI::HangHuman()
- {
- return std::async(std::launch::async, [&]()
- { return logic.HangHuman(); });
- }
-
- std::shared_ptr<const THUAI6::Butcher> ButcherAPI::GetSelfInfo() const
- {
- return logic.ButcherGetSelfInfo();
- }
-
- void HumanAPI::Play(IAI& ai)
- {
- ai.play(*this);
- }
-
- void ButcherAPI::Play(IAI& ai)
- {
- ai.play(*this);
- }
|