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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 platform
  12. import PyAPI.structures as THUAI6
  13. def PrintWelcomeString() -> None:
  14. # Generated by http://www.network-science.de/ascii/ with font "standard"
  15. welcomeString = """
  16. _____ _ _ _ _ _ ___ __
  17. |_ _| | | | | | | / \ |_ _/ /_
  18. | | | |_| | | | |/ _ \ | | '_ \
  19. | | | _ | |_| / ___ \ | | (_) |
  20. |_| |_| |_|\___/_/ \_\___\___/
  21. ____ _ _ ____ _ _ _
  22. / ___|_ __ __ _ __| |_ _ __ _| |_ ___ / ___(_)_ __| |___| |
  23. | | _| '__/ _` |/ _` | | | |/ _` | __/ _ \ | | _| | '__| / __| |
  24. | |_| | | | (_| | (_| | |_| | (_| | || __/_ | |_| | | | | \__ \_|
  25. \____|_| \__,_|\__,_|\__,_|\__,_|\__\___( ) \____|_|_| |_|___(_)
  26. """
  27. print(welcomeString)
  28. def THUAI6Main(argv: List[str], AIBuilder: Callable) -> None:
  29. pID: int = 0
  30. sIP: str = "127.0.0.1"
  31. sPort: str = "8888"
  32. file: bool = True
  33. screen: bool = True
  34. warnOnly: bool = False
  35. parser = argparse.ArgumentParser(
  36. description="THUAI6 Python Interface Commandline Parameter Introduction")
  37. parser.add_argument("-I", type=str, required=True,
  38. help="Server`s IP 127.0.0.1 in default", dest="sIP", default="127.0.0.1")
  39. parser.add_argument("-P", type=str, required=True,
  40. help="Server`s Port 8888 in default", dest="sPort", default="8888")
  41. parser.add_argument("-p", type=int, required=True,
  42. help="Player`s ID", dest="pID", choices=[0, 1, 2, 3, 4])
  43. parser.add_argument("-d", action='store_true',
  44. help="Set this flag to save the debug log to ./logs folder", dest="file")
  45. parser.add_argument("-o", action='store_true',
  46. help="Set this flag to print the debug log to the screen", dest="screen")
  47. parser.add_argument("-w", action='store_true',
  48. help="Set this flag to only print warning on the screen", dest="warnOnly")
  49. args = parser.parse_args()
  50. pID = args.pID
  51. sIP = args.sIP
  52. sPort = args.sPort
  53. file = args.file
  54. screen = args.screen
  55. warnOnly = args.warnOnly
  56. playerType = THUAI6.PlayerType.NullPlayerType
  57. if pID == 4:
  58. playerType = THUAI6.PlayerType.TrickerPlayer
  59. else:
  60. playerType = THUAI6.PlayerType.StudentPlayer
  61. if platform.system().lower() == "windows":
  62. PrintWelcomeString()
  63. logic = Logic(pID, playerType)
  64. logic.Main(AIBuilder, sIP, sPort, file, screen, warnOnly)
  65. def CreateAI(pID: int) -> IAI:
  66. return AI(pID)
  67. if __name__ == '__main__':
  68. THUAI6Main(sys.argv, CreateAI)