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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import PyAPI.structures as THUAI6
  2. from PyAPI.Interface import IStudentAPI, ITrickerAPI, IAI
  3. from typing import Union, Final, cast
  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. # 选手必须修改该函数的返回值来选择自己的阵营
  13. @staticmethod
  14. def playerType() -> THUAI6.PlayerType:
  15. return THUAI6.PlayerType.StudentPlayer
  16. # 选手需要将两个都定义,本份代码中不选择的阵营任意定义即可
  17. @staticmethod
  18. def studentType() -> THUAI6.StudentType:
  19. return THUAI6.StudentType.Athlete
  20. @staticmethod
  21. def trickerType() -> THUAI6.TrickerType:
  22. return THUAI6.TrickerType.Assassin
  23. # 辅助函数
  24. numOfGridPerCell: Final[int] = 1000
  25. class AssistFunction:
  26. @staticmethod
  27. def CellToGrid(cell: int) -> int:
  28. return cell * numOfGridPerCell + numOfGridPerCell // 2
  29. @staticmethod
  30. def GridToCell(grid: int) -> int:
  31. return grid // numOfGridPerCell
  32. class AI(IAI):
  33. # 选手在这里实现自己的逻辑,要求和上面选择的阵营保持一致
  34. def StudentPlay(self, api: IStudentAPI) -> None:
  35. selfInfo = api.GetSelfInfo()
  36. api.PrintSelfInfo()
  37. return
  38. def TrickerPlay(self, api: ITrickerAPI) -> None:
  39. selfInfo = api.GetSelfInfo()
  40. api.PrintSelfInfo()
  41. return