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.

main.py 2.1 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import os
  2. import sys
  3. sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
  4. sys.path.append(os.path.dirname(os.path.dirname(
  5. os.path.realpath(__file__))) + '/proto')
  6. from PyAPI.Interface import IAI
  7. from PyAPI.AI import AI
  8. from PyAPI.logic import Logic
  9. from typing import List, Callable
  10. import argparse
  11. import PyAPI.structures as THUAI6
  12. def THUAI6Main(argv: List[str], AIBuilder: Callable) -> None:
  13. pID: int = 0
  14. sIP: str = "127.0.0.1"
  15. sPort: str = "8888"
  16. file: bool = True
  17. screen: bool = True
  18. warnOnly: bool = False
  19. parser = argparse.ArgumentParser(
  20. description="THUAI6 Python Interface Commandline Parameter Introduction")
  21. parser.add_argument("-I", type=str, required=True,
  22. help="Server`s IP 127.0.0.1 in default", dest="sIP", default="127.0.0.1")
  23. parser.add_argument("-P", type=str, required=True,
  24. help="Server`s Port 8888 in default", dest="sPort", default="8888")
  25. parser.add_argument("-p", type=int, required=True,
  26. help="Player`s ID", dest="pID", choices=[0, 1, 2, 3, 4])
  27. parser.add_argument("-d", action='store_true',
  28. help="Set this flag to save the debug log to ./logs folder", dest="file")
  29. parser.add_argument("-o", action='store_true',
  30. help="Set this flag to print the debug log to the screen", dest="screen")
  31. parser.add_argument("-w", action='store_true',
  32. help="Set this flag to only print warning on the screen", dest="warnOnly")
  33. args = parser.parse_args()
  34. pID = args.pID
  35. sIP = args.sIP
  36. sPort = args.sPort
  37. file = args.file
  38. screen = args.screen
  39. warnOnly = args.warnOnly
  40. playerType = THUAI6.PlayerType.NullPlayerType
  41. if pID == 4:
  42. playerType = THUAI6.PlayerType.TrickerPlayer
  43. else:
  44. playerType = THUAI6.PlayerType.StudentPlayer
  45. logic = Logic(pID, playerType)
  46. logic.Main(AIBuilder, sIP, sPort, file, screen, warnOnly)
  47. def CreateAI(pID: int) -> IAI:
  48. return AI(pID)
  49. if __name__ == '__main__':
  50. THUAI6Main(sys.argv, CreateAI)