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.

rank.py 8.6 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. import os
  2. import json
  3. import re
  4. winGamesMap = {}
  5. totalGamesMap = {}
  6. studentTotalGame = {}
  7. trickerTotalGame = {}
  8. winRateMap = {}
  9. studentWinMap = {}
  10. trickerWinMap = {}
  11. studentWinRateMap = {}
  12. trickerWinRateMap = {}
  13. winGamesMap1 = {}
  14. totalGamesMap1 = {}
  15. studentTotalGame1 = {}
  16. trickerTotalGame1 = {}
  17. winRateMap1 = {}
  18. studentWinMap1 = {}
  19. trickerWinMap1 = {}
  20. studentWinRateMap1 = {}
  21. trickerWinRateMap1 = {}
  22. studentWinNum = 0
  23. trickerWinNum = 0
  24. totalGameNum = 0
  25. studentWinNum1 = 0
  26. trickerWinNum1 = 0
  27. totalGameNum1 = 0
  28. teamIDtoName = {
  29. "951c89eb-aa9c-45d4-af10-ad9785a047d6": "无名万物之始", "2e504ec6-50b1-4985-b2fd-995927ea9717": "LQ说什么都队", "fb472ad6-65e0-494b-a7be-f6f25ecda018": "是啊我诶",
  30. "3376909b-5ddb-41ab-994c-3c5b5ba60158": "叛逃者联盟",
  31. "9b0f2257-734c-42e2-8061-c267e3d0d231": "ChatGPA",
  32. "2de908c9-1b99-4811-ae00-68140d1c4527": "昊天上帝和他的三个神父",
  33. "94866510-af51-439c-a41a-b4cb42596e25": "少年毕不了业",
  34. "4613ef48-4988-4508-a258-66857a3250b8": "PKT48TeamTS",
  35. "8e14b2a3-fc37-4fb6-b8ac-a722a10707d7": "京ICP备2022019669号-1 2022 EESAST",
  36. "e8db213c-a636-483f-a6ed-84310b3093a4": "拉拉队",
  37. "04abd472-ed7a-4840-8680-87d20db52721": "努力少女戏尔危",
  38. "2bc1b761-ace3-4403-af83-e46ca328bcd0": "测试",
  39. "4c1d6333-e25c-4b0f-bc06-9851db446bd7": "摆烂吧,少女",
  40. "7f819704-99c0-41d8-bc61-26eec0bd73bb": "一会吃萤火虫",
  41. "de915bbf-0751-4a9d-ab30-a470807406b2": "小小做题家",
  42. "28baa2bf-5130-4a1e-ab9c-36e8faf87f84": "数析少女队",
  43. "5c868c42-3b07-4280-a825-a6f80e0d5a2c": "沙壁北京",
  44. "ed03d1ac-810a-4547-b54a-d56cd5213364": "我会出手队",
  45. "5d59e45f-cb0e-4294-90f4-282adb1d476d": "闪电骑士团",
  46. "637e20c1-a904-4f6f-b706-2cea7c4daf5e": "Mukava Poikaa",
  47. "7185eb49-0cb0-43c0-a469-a39e636d66d4": "劝退吧,少女",
  48. "d2a7ba71-4a86-4278-a362-8a8953a368f8": "纵火犯在何方",
  49. "4e266301-7749-4699-b2de-511d458cf537": "土木清华没有水",
  50. "454f37bd-2f54-4463-94d9-2df9aedb4f21": "电电做不队",
  51. "a2573713-28e4-4af7-8c53-ab21f385f789": "王牌飞行队",
  52. "194c3ddf-6846-47ec-a262-ca24f5639531": "快乐Debug",
  53. "97cf5969-e8ff-410e-b85c-0c8359923289": "卷动量守恒",
  54. "4646739a-9ff5-4854-a3b2-27d5b85ea504": "龙井队",
  55. "c431d105-a2b3-4659-b713-6bc97132ec7f": "疯狂Thurs队",
  56. "9ee48de1-a76a-40eb-b267-59c985bbe6cb": "蒸馍",
  57. "5ef8ffbb-0776-4a74-a84f-3d80d5b4c2ae": "你说什么都队",
  58. "65f94306-69c7-42a2-8c68-44cb45749aae": "closeAI",
  59. "ab0406ae-6a0e-4c1e-9d36-eb14115de076": "N/A",
  60. "82cbff06-9ed1-429b-afc3-7e050318bf93": "代码一行都不队",
  61. "6b52346c-4528-424b-ac75-22fa573ebaad": "pqfobj",
  62. "93e7f3f1-d47f-4588-b433-72877089f0bd": "你说得队",
  63. "2f6f9ce3-f2d3-4799-b291-38dc04d048a0": "少女终末旅行",
  64. "07c0ad6c-f612-4375-9b79-52bb89c79d76": "大括号换行委员会",
  65. "bdf5b1c5-4dbc-4589-a6bc-8c5932c04de7": "孤客若风",
  66. "f0d75eee-34a6-4484-8e23-720d26db747d": "/",
  67. "acea715f-d5b0-4113-b6c3-9f6d7822f2e9": "难崩"
  68. }
  69. dirs = os.listdir(".")
  70. for dir in dirs:
  71. if dir.startswith("Team"):
  72. dirdir = dir.replace("Team_", "")
  73. dirdir = dirdir.split("--vs--")
  74. try:
  75. with open(f"{dir}/result.json", 'r') as f:
  76. result = json.load(f)
  77. for i in (0, 1):
  78. if dirdir[i] not in winGamesMap:
  79. winGamesMap[dirdir[i]] = 0
  80. if dirdir[i] not in totalGamesMap:
  81. totalGamesMap[dirdir[i]] = 0
  82. if dirdir[i] not in studentWinMap:
  83. studentWinMap[dirdir[i]] = 0
  84. if dirdir[i] not in trickerWinMap:
  85. trickerWinMap[dirdir[i]] = 0
  86. if dirdir[i] not in studentTotalGame:
  87. studentTotalGame[dirdir[i]] = 0
  88. if dirdir[i] not in trickerTotalGame:
  89. trickerTotalGame[dirdir[i]] = 0
  90. if dirdir[i] not in winGamesMap1:
  91. winGamesMap1[dirdir[i]] = 0
  92. if dirdir[i] not in totalGamesMap1:
  93. totalGamesMap1[dirdir[i]] = 0
  94. if dirdir[i] not in studentWinMap1:
  95. studentWinMap1[dirdir[i]] = 0
  96. if dirdir[i] not in trickerWinMap1:
  97. trickerWinMap1[dirdir[i]] = 0
  98. if dirdir[i] not in studentTotalGame1:
  99. studentTotalGame1[dirdir[i]] = 0
  100. if dirdir[i] not in trickerTotalGame1:
  101. trickerTotalGame1[dirdir[i]] = 0
  102. totalGamesMap[dirdir[0]] += 1
  103. totalGamesMap[dirdir[1]] += 1
  104. studentTotalGame[dirdir[0]] += 1
  105. trickerTotalGame[dirdir[1]] += 1
  106. totalGameNum += 1
  107. if result["Student"] < result["Tricker"]:
  108. winGamesMap[dirdir[1]] += 1
  109. trickerWinMap[dirdir[1]] += 1
  110. trickerWinNum += 1
  111. elif result["Student"] > result["Tricker"]:
  112. winGamesMap[dirdir[0]] += 1
  113. studentWinMap[dirdir[0]] += 1
  114. studentWinNum += 1
  115. else:
  116. winGamesMap[dirdir[0]] += 0.5
  117. winGamesMap[dirdir[1]] += 0.5
  118. if result["Student"] != 0 and result["Tricker"] != 0:
  119. totalGameNum1 += 1
  120. totalGamesMap1[dirdir[0]] += 1
  121. totalGamesMap1[dirdir[1]] += 1
  122. studentTotalGame1[dirdir[0]] += 1
  123. trickerTotalGame1[dirdir[1]] += 1
  124. if result["Student"] < result["Tricker"]:
  125. winGamesMap1[dirdir[1]] += 1
  126. trickerWinMap1[dirdir[1]] += 1
  127. trickerWinNum1 += 1
  128. elif result["Student"] > result["Tricker"]:
  129. winGamesMap1[dirdir[0]] += 1
  130. studentWinMap1[dirdir[0]] += 1
  131. studentWinNum1 += 1
  132. else:
  133. winGamesMap1[dirdir[0]] += 0.5
  134. winGamesMap1[dirdir[1]] += 0.5
  135. except:
  136. pass
  137. for i in totalGamesMap:
  138. winRateMap[i] = winGamesMap[i] / totalGamesMap[i]
  139. if studentTotalGame[i] == 0:
  140. studentWinRateMap[i] = 0
  141. else:
  142. studentWinRateMap[i] = studentWinMap[i] / studentTotalGame[i]
  143. if trickerTotalGame[i] == 0:
  144. trickerWinRateMap[i] = 0
  145. else:
  146. trickerWinRateMap[i] = trickerWinMap[i] / trickerTotalGame[i]
  147. sortedMap = sorted(winRateMap.items(), key=lambda kv: (
  148. kv[1], kv[0]), reverse=True)
  149. print("************************ALL GAMES(with 0 player)************************")
  150. for i in sortedMap:
  151. width = 33 - len(re.findall('([\u4e00-\u9fa5])', teamIDtoName[i[0]]))
  152. print(
  153. f"Team {teamIDtoName[i[0]]:{width}}({i[0]}) wins {winGamesMap[i[0]]:4}/{totalGamesMap[i[0]]:<2} games({i[1]:.3f}), student wins {studentWinMap[i[0]]:2}/{studentTotalGame[i[0]]:<2}({studentWinRateMap[i[0]]:.3f}), tricker wins {trickerWinMap[i[0]]:2}/{trickerTotalGame[i[0]]:<2}({trickerWinRateMap[i[0]]:.3f})")
  154. print(
  155. f"Total games: {totalGameNum}, student wins {studentWinNum}, tricker wins {trickerWinNum}")
  156. for i in totalGamesMap1:
  157. if totalGamesMap1[i] == 0:
  158. winRateMap1[i] = 0
  159. else:
  160. winRateMap1[i] = winGamesMap1[i] / totalGamesMap1[i]
  161. if studentTotalGame1[i] == 0:
  162. studentWinRateMap1[i] = 0
  163. else:
  164. studentWinRateMap1[i] = studentWinMap1[i] / studentTotalGame1[i]
  165. if trickerTotalGame1[i] == 0:
  166. trickerWinRateMap1[i] = 0
  167. else:
  168. trickerWinRateMap1[i] = trickerWinMap1[i] / trickerTotalGame1[i]
  169. sortedMap1 = sorted(winRateMap1.items(), key=lambda kv: (
  170. kv[1], kv[0]), reverse=True)
  171. print("************************NON-0 GAMES(no 0 player)************************")
  172. for i in sortedMap1:
  173. width = 33 - len(re.findall('([\u4e00-\u9fa5])', teamIDtoName[i[0]]))
  174. print(f"Team {teamIDtoName[i[0]]:{width}}({i[0]}) wins {winGamesMap1[i[0]]:4}/{totalGamesMap1[i[0]]:<2} games({i[1]:.3f}), student wins {studentWinMap1[i[0]]:2}/{studentTotalGame1[i[0]]:<2}({studentWinRateMap1[i[0]]:.3f}), tricker wins {trickerWinMap1[i[0]]:2}/{trickerTotalGame1[i[0]]:<2}({trickerWinRateMap1[i[0]]:.3f})")
  175. print(
  176. f"Total games: {totalGameNum1}, student wins {studentWinNum1}, tricker wins {trickerWinNum1}")