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.py 1.8 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import PyAPI.structures as THUAI6
  2. from PyAPI.Interface import IStudentAPI, ITrickerAPI, IAI
  3. from typing import Union, Final, cast, List
  4. from PyAPI.constants import Constants
  5. import queue
  6. import time
  7. class Setting:
  8. # 为假则play()期间确保游戏状态不更新,为真则只保证游戏状态在调用相关方法时不更新
  9. @staticmethod
  10. def asynchronous() -> bool:
  11. return True
  12. # 选手需要依次将player0到player4的职业都定义
  13. @staticmethod
  14. def studentType() -> List[THUAI6.StudentType]:
  15. return [THUAI6.StudentType.Athlete, THUAI6.StudentType.Teacher, THUAI6.StudentType.StraightAStudent, THUAI6.StudentType.Sunshine]
  16. @staticmethod
  17. def trickerType() -> THUAI6.TrickerType:
  18. return THUAI6.TrickerType.Assassin
  19. # 辅助函数
  20. numOfGridPerCell: Final[int] = 1000
  21. class AssistFunction:
  22. @staticmethod
  23. def CellToGrid(cell: int) -> int:
  24. return cell * numOfGridPerCell + numOfGridPerCell // 2
  25. @staticmethod
  26. def GridToCell(grid: int) -> int:
  27. return grid // numOfGridPerCell
  28. class AI(IAI):
  29. def __init__(self, pID: int):
  30. self.__playerID = pID
  31. # 选手在这里实现自己的逻辑,要求和上面选择的阵营保持一致
  32. def StudentPlay(self, api: IStudentAPI) -> None:
  33. if self.__playerID == 0:
  34. # 玩家0执行操作
  35. return
  36. elif self.__playerID == 1:
  37. # 玩家1执行操作
  38. return
  39. elif self.__playerID == 2:
  40. # 玩家2执行操作
  41. return
  42. elif self.__playerID == 3:
  43. # 玩家3执行操作
  44. return
  45. return
  46. def TrickerPlay(self, api: ITrickerAPI) -> None:
  47. selfInfo = api.GetSelfInfo()
  48. api.PrintSelfInfo()
  49. return