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.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import PyAPI.structures as THUAI6
  2. from PyAPI.Interface import IStudentAPI, ITrickerAPI, IAI
  3. from typing import Union, Final
  4. class Setting:
  5. # 为假则play()期间确保游戏状态不更新,为真则只保证游戏状态在调用相关方法时不更新
  6. @staticmethod
  7. def asynchronous() -> bool:
  8. return False
  9. # 选手必须修改该函数的返回值来选择自己的阵营
  10. @staticmethod
  11. def playerType() -> THUAI6.PlayerType:
  12. return THUAI6.PlayerType.StudentPlayer
  13. # 选手需要将两个都定义,本份代码中不选择的阵营任意定义即可
  14. @staticmethod
  15. def studentType() -> THUAI6.StudentType:
  16. return THUAI6.StudentType.StudentType1
  17. @staticmethod
  18. def trickerType() -> THUAI6.TrickerType:
  19. return THUAI6.TrickerType.TrickerType1
  20. # 辅助函数
  21. numOfGridPerCell: Final[int] = 1000
  22. class AssistFunction:
  23. @staticmethod
  24. def CellToGrid(cell: int) -> int:
  25. return cell * numOfGridPerCell + numOfGridPerCell // 2
  26. @staticmethod
  27. def GridToCell(grid: int) -> int:
  28. return grid // numOfGridPerCell
  29. class AI(IAI):
  30. def play(self, api: Union[IStudentAPI, ITrickerAPI]) -> None:
  31. # 选手在这里实现自己的逻辑,要求和上面选择的阵营保持一致,否则会发生错误
  32. return