You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

AI.cpp 1.5 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #include <vector>
  2. #include <thread>
  3. #include <array>
  4. #include "AI.h"
  5. #include "constants.h"
  6. // 注意不要使用conio.h,Windows.h等非标准库
  7. // 为假则play()期间确保游戏状态不更新,为真则只保证游戏状态在调用相关方法时不更新,大致一帧更新一次
  8. extern const bool asynchronous = false;
  9. // 选手需要依次将player0到player4的职业在这里定义
  10. extern const std::array<THUAI6::StudentType, 4> studentType = {
  11. THUAI6::StudentType::Athlete,
  12. THUAI6::StudentType::Teacher,
  13. THUAI6::StudentType::StraightAStudent,
  14. THUAI6::StudentType::Sunshine};
  15. extern const THUAI6::TrickerType trickerType = THUAI6::TrickerType::Assassin;
  16. // 可以在AI.cpp内部声明变量与函数
  17. void AI::play(IStudentAPI& api) // 每帧执行一次AI::play(IStudentAPI& api)或AI::play(ITrickerAPI& api)(除非执行该函数超过一帧50ms),获取的信息都是这一帧的开始的状态
  18. {
  19. // 公共操作
  20. if (this->playerID == 0)
  21. {
  22. // 玩家0执行操作
  23. }
  24. else if (this->playerID == 1)
  25. {
  26. // 玩家1执行操作
  27. }
  28. else if (this->playerID == 2)
  29. {
  30. // 玩家2执行操作
  31. }
  32. else if (this->playerID == 3)
  33. {
  34. // 玩家3执行操作
  35. }
  36. // 当然可以写成if (this->playerID == 2||this->playerID == 3)之类的操作
  37. // 公共操作
  38. }
  39. void AI::play(ITrickerAPI& api)
  40. {
  41. auto self = api.GetSelfInfo();
  42. api.PrintSelfInfo();
  43. }