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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import PyAPI.structures as THUAI6
  2. from PyAPI.Interface import IStudentAPI, ITrickerAPI, IAI
  3. from typing import Union, Final, cast
  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.Athlete
  17. @staticmethod
  18. def trickerType() -> THUAI6.TrickerType:
  19. return THUAI6.TrickerType.Assassin
  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. # 选手在这里实现自己的逻辑,要求和上面选择的阵营保持一致
  31. def StudentPlay(self, api: IStudentAPI) -> None:
  32. # studentSelf = api.GetSelfInfo()
  33. # api.PrintSelfInfo()
  34. # if AssistFunction.GridToCell(studentSelf.y) < 8:
  35. # api.MoveRight(50)
  36. # return
  37. # if studentSelf.x < 3600:
  38. # api.MoveDown(50)
  39. # return
  40. # if studentSelf.playerState == THUAI6.PlayerState.Idle:
  41. # if api.GetClassroomProgress(5, 8) < 114514:
  42. # api.StartLearning()
  43. # return
  44. api.PrintTricker()
  45. return
  46. def TrickerPlay(self, api: ITrickerAPI) -> None:
  47. return