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 1.9 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. def THUAI6Main(argv: List[str], AIBuilder: Callable) -> None:
  12. pID: int = 0
  13. sIP: str = "127.0.0.1"
  14. sPort: str = "8888"
  15. file: bool = True
  16. screen: bool = True
  17. warnOnly: bool = False
  18. parser = argparse.ArgumentParser(
  19. description="THUAI6 Python Interface Commandline Parameter Introduction")
  20. parser.add_argument("-I", type=str, required=True,
  21. help="Server`s IP 127.0.0.1 in default", dest="sIP", default="127.0.0.1")
  22. parser.add_argument("-P", type=str, required=True,
  23. help="Server`s Port 8888 in default", dest="sPort", default="8888")
  24. parser.add_argument("-p", type=int, required=True,
  25. help="Player`s ID", dest="pID", choices=[0, 1, 2, 3, 4])
  26. parser.add_argument("-d", action='store_true',
  27. help="Set this flag to save the debug log to ./logs folder", dest="file")
  28. parser.add_argument("-o", action='store_true',
  29. help="Set this flag to print the debug log to the screen", dest="screen")
  30. parser.add_argument("-w", action='store_true',
  31. help="Set this flag to only print warning on the screen", dest="warnOnly")
  32. args = parser.parse_args()
  33. pID = args.pID
  34. sIP = args.sIP
  35. sPort = args.sPort
  36. file = args.file
  37. screen = args.screen
  38. warnOnly = args.warnOnly
  39. logic = Logic(pID)
  40. logic.Main(AIBuilder, sIP, sPort, file, screen, warnOnly)
  41. def CreateAI() -> IAI:
  42. return AI()
  43. if __name__ == '__main__':
  44. THUAI6Main(sys.argv, CreateAI)