shapeGen.py 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948
  1. import random
  2. import game.const.game as G
  3. import game.const.rouge as R
  4. import game.const.rouge_theme as T
  5. def randomDistrictAllocation(n, alpha, beta, minDiff, minName, mon_dic, cell_type, symmetric=False):
  6. # 其中n为该区难度
  7. # alpha为第二只及以上的重复怪物的权重系数,取值范围(0,1),通常为0.5
  8. # beta为怪的随机变难因子(容忍最后加的这只怪最终超出地图难度多少) ( max{单怪难度+剩余可分配难度}=beta ),通常为8
  9. # minDiff为进行随机抽取的最低剩余可分配难度,当剩余难度比此值低时则强制选取1只怪,通常为3
  10. # minName为字符串:"**",即强制选取的怪物名称
  11. break_time = 0
  12. district=[]
  13. diffList=[]
  14. # 初始化三个空的列表,用于存储不同类型的主键
  15. normal_keys = []
  16. elite_keys = []
  17. boss_keys = []
  18. normal_elite_keys = []
  19. elite_boss_keys = []
  20. all_keys = []
  21. has_boss = False
  22. # 遍历原始字典,根据"type"字段分类主键
  23. for key, value in mon_dic.items():
  24. if value['type'] == 'normal':
  25. normal_keys.append(key)
  26. normal_elite_keys.append(key)
  27. all_keys.append(key)
  28. elif value['type'] == 'elite':
  29. elite_keys.append(key)
  30. normal_elite_keys.append(key)
  31. elite_boss_keys.append(key)
  32. all_keys.append(key)
  33. elif value['type'] == 'boss':
  34. boss_keys.append(key)
  35. elite_boss_keys.append(key)
  36. all_keys.append(key)
  37. if cell_type == "single_boss" or cell_type == "mix_boss":
  38. n = int(n*1.2)
  39. if R.difficulty == "Easy":
  40. rd = random.randint(0,1)
  41. elif R.difficulty == "Normal":
  42. rd = random.randint(-1,1)
  43. else:
  44. rd = random.randint(-2,1)
  45. while sum(diffList) < n:
  46. name = None
  47. break_time += 1
  48. if len(district) > 5-random.randint(0,1):
  49. break
  50. else:
  51. if R.difficulty == "Easy" and len(district) > 4-random.randint(0,1):
  52. break
  53. if cell_type == "elite":
  54. if len(district) > R.diff_elite_num[R.difficulty]-rd:
  55. break
  56. if cell_type == "elite_normal":
  57. if len(district) > R.diff_elite_normal_num[R.difficulty]-rd:
  58. break
  59. if break_time >= 10000:
  60. if cell_type == "single_boss" or "mix_boss":
  61. name = random.choice(normal_elite_keys)
  62. district.append(name)
  63. diffList.append(mon_dic[name]["diff"])
  64. else:
  65. district.append(minName)
  66. diffList.append(minDiff)
  67. break
  68. # 开始分怪
  69. if cell_type == "normal":
  70. name = random.choice(normal_keys)
  71. if cell_type == "normal_elite":
  72. name = random.choice(normal_elite_keys)
  73. if cell_type == "elite":
  74. name = random.choice(elite_keys)
  75. if cell_type == "single_boss":
  76. name = random.choice(boss_keys)
  77. if cell_type == "mix_boss":
  78. if not has_boss:
  79. has_boss = True
  80. name = random.choice(boss_keys)
  81. else:
  82. name = random.choice(elite_boss_keys)
  83. if break_time >= 1000:
  84. if cell_type == "single_boss" or "mix_boss":
  85. name = random.choice(normal_elite_keys)
  86. difficulty = mon_dic[name]["diff"]
  87. if district.count(name) >= mon_dic[name]["max"] or (symmetric and mon_dic[name]["max"]<=2):
  88. continue
  89. if district.count(name) >= 1:
  90. difficulty = round(difficulty * (alpha + (1.5*(1-alpha))/district.count(name)),1)
  91. if n-sum(diffList)<=minDiff:
  92. district.append(minName)
  93. diffList.append(minDiff+1)
  94. continue
  95. else:
  96. if difficulty > n-sum(diffList)+beta:
  97. continue
  98. else:
  99. if district.count(name) == 0:
  100. difficulty = max(difficulty*1.4, difficulty+6)
  101. district.append(name)
  102. diffList.append(difficulty)
  103. # print(diffList,",难度系数=", sum(diffList))
  104. return district, diffList
  105. def setable(list):
  106. return [tuple(item) for item in list]
  107. def generalDistrictMapSpawn(n, alpha, beta, minDiff, minName, mon_dic, cell_type, besiege, wallNum, cubeNum):
  108. # 前几个参数和分区函数相同
  109. # besiege表示每个怪物被墙围住的概率%(0-100)
  110. # wallNum, cubeANum, cubeBNum为三种障碍物的最大上限数量(一般wallNum=5, 15<cubeNum<64)
  111. # wall为不可摧毁墙;
  112. monsters = []
  113. if random.randint(1, 100) >= 88:
  114. hole_type = random.randint(1,14)
  115. if hole_type == 1:
  116. coordinates = [[7,7],[7,8],[7,9],[8,7],[8,8],[8,9],[9,7],[9,8],[9,9]]
  117. obstacles=[[7,7],[7,8],[7,9],[8,7],[8,8],[8,9],[9,7],[9,8],[9,9]]
  118. wall=[[7,7],[7,8],[7,9],[8,7],[8,8],[8,9],[9,7],[9,8],[9,9]]
  119. wallNum = 0
  120. elif hole_type == 2:
  121. coordinates = [[7,7],[7,8],[7,9],[8,7],[8,8],[8,9],[9,7],[9,8],[9,9],[6,8],[8,6],[8,10],[10,8]]
  122. obstacles=[[7,7],[7,8],[7,9],[8,7],[8,8],[8,9],[9,7],[9,8],[9,9],[6,8],[8,6],[8,10],[10,8]]
  123. wall=[[7,7],[7,8],[7,9],[8,7],[8,8],[8,9],[9,7],[9,8],[9,9],[6,8],[8,6],[8,10],[10,8]]
  124. wallNum = 0
  125. elif hole_type == 3:
  126. coordinates = [[6,7],[7,6],[7,7], [9,6],[9,7],[10,7], [6,9],[7,9],[7,10], [9,9],[9,10],[10,9]]
  127. obstacles = [[6,7],[7,6],[7,7], [9,6],[9,7],[10,7], [6,9],[7,9],[7,10], [9,9],[9,10],[10,9]]
  128. wall = [[6,7],[7,6],[7,7], [9,6],[9,7],[10,7], [6,9],[7,9],[7,10], [9,9],[9,10],[10,9]]
  129. wallNum = 0
  130. elif hole_type == 4:
  131. coordinates = [[7,8],[8,7],[8,8],[8,9],[9,8], [4,4],[4,5],[5,4],[5,5], [11,11],[11,12],[12,11],[12,12], [11,4],[11,5],[12,4],[12,5], [4,11],[4,12],[5,11],[5,12]]
  132. obstacles = [[7,8],[8,7],[8,8],[8,9],[9,8], [4,4],[4,5],[5,4],[5,5], [11,11],[11,12],[12,11],[12,12], [11,4],[11,5],[12,4],[12,5], [4,11],[4,12],[5,11],[5,12]]
  133. wall = [[7,8],[8,7],[8,8],[8,9],[9,8], [4,4],[4,5],[5,4],[5,5], [11,11],[11,12],[12,11],[12,12], [11,4],[11,5],[12,4],[12,5], [4,11],[4,12],[5,11],[5,12]]
  134. wallNum = 0
  135. elif hole_type == 5: # 四宫格
  136. coordinates = [[2,8],[3,8],[4,8],[5,8],[6,8],[7,9],[8,10],[8,13],[8,14],[8,2],[8,3],[8,6],[9,7],[10,8],[11,8],[12,8],[13,8],[14,8]]
  137. obstacles = [[2,8],[3,8],[4,8],[5,8],[6,8],[7,9],[8,10],[8,13],[8,14],[8,2],[8,3],[8,6],[9,7],[10,8],[11,8],[12,8],[13,8],[14,8]]
  138. wall = [[2,8],[3,8],[4,8],[5,8],[6,8],[7,9],[8,10],[8,13],[8,14],[8,2],[8,3],[8,6],[9,7],[10,8],[11,8],[12,8],[13,8],[14,8]]
  139. wallNum = 0
  140. elif hole_type == 6:
  141. coordinates = [[5,7],[5,9],[6,6],[6,10],[7,5],[7,11],[11,7],[11,9],[10,6],[10,10],[9,5],[9,11]]
  142. obstacles = [[5,7],[5,9],[6,6],[6,10],[7,5],[7,11],[11,7],[11,9],[10,6],[10,10],[9,5],[9,11]]
  143. wall = [[5,7],[5,9],[6,6],[6,10],[7,5],[7,11],[11,7],[11,9],[10,6],[10,10],[9,5],[9,11]]
  144. wallNum = 0
  145. elif hole_type == 7: # 散点地形
  146. coordinates = [(7, 7), (7, 9), (9, 9), (9, 7), (11, 8), (8, 5), (5, 8), (8, 11), (7, 13), (9, 13), (11, 13), (13, 12), (5, 13), (3, 12), (3, 10), (13, 10), (7, 3), (9, 3), (11, 3), (5, 3), (3, 4), (3, 6), (13, 6), (13, 4), (3, 8), (13, 8)]
  147. obstacles = [(7, 7), (7, 9), (9, 9), (9, 7), (11, 8), (8, 5), (5, 8), (8, 11), (7, 13), (9, 13), (11, 13), (13, 12), (5, 13), (3, 12), (3, 10), (13, 10), (7, 3), (9, 3), (11, 3), (5, 3), (3, 4), (3, 6), (13, 6), (13, 4), (3, 8), (13, 8)]
  148. wall = [(7, 7), (7, 9), (9, 9), (9, 7), (11, 8), (8, 5), (5, 8), (8, 11), (7, 13), (9, 13), (11, 13), (13, 12), (5, 13), (3, 12), (3, 10), (13, 10), (7, 3), (9, 3), (11, 3), (5, 3), (3, 4), (3, 6), (13, 6), (13, 4), (3, 8), (13, 8)]
  149. wallNum = 0
  150. elif hole_type == 8: # sqrt13
  151. coordinates = [(3, 11), (5, 11), (6, 9), (6, 8), (6, 7), (7, 4), (8, 4), (9, 4), (10, 4), (11, 4), (12, 4), (8, 8), (8, 9), (8, 10), (8, 11), (6, 6), (8, 7), (8, 6), (10, 6), (11, 6), (12, 7), (12, 8), (11, 9), (10, 9), (12, 10), (12, 11), (11, 12), (10, 12), (8, 12), (6, 10), (5, 12), (4, 10), (3, 12)]
  152. obstacles = [(3, 11), (5, 11), (6, 9), (6, 8), (6, 7), (7, 4), (8, 4), (9, 4), (10, 4), (11, 4), (12, 4), (8, 8), (8, 9), (8, 10), (8, 11), (6, 6), (8, 7), (8, 6), (10, 6), (11, 6), (12, 7), (12, 8), (11, 9), (10, 9), (12, 10), (12, 11), (11, 12), (10, 12), (8, 12), (6, 10), (5, 12), (4, 10), (3, 12)]
  153. wall = [(3, 11), (5, 11), (6, 9), (6, 8), (6, 7), (7, 4), (8, 4), (9, 4), (10, 4), (11, 4), (12, 4), (8, 8), (8, 9), (8, 10), (8, 11), (6, 6), (8, 7), (8, 6), (10, 6), (11, 6), (12, 7), (12, 8), (11, 9), (10, 9), (12, 10), (12, 11), (11, 12), (10, 12), (8, 12), (6, 10), (5, 12), (4, 10), (3, 12)]
  154. wallNum = 0
  155. elif hole_type == 9: # 关机图标
  156. coordinates = [(4, 10), (4, 9), (4, 8), (7, 12), (9, 12), (5, 11), (6, 11), (10, 11), (11, 11), (12, 10), (12, 9), (12, 8), (12, 7), (4, 7), (5, 6), (11, 6), (8, 3), (8, 4), (8, 5), (8, 6), (8, 7), (8, 8), (8, 9), (10, 5), (6, 5), (8, 12)]
  157. obstacles = [(4, 10), (4, 9), (4, 8), (7, 12), (9, 12), (5, 11), (6, 11), (10, 11), (11, 11), (12, 10), (12, 9), (12, 8), (12, 7), (4, 7), (5, 6), (11, 6), (8, 3), (8, 4), (8, 5), (8, 6), (8, 7), (8, 8), (8, 9), (10, 5), (6, 5), (8, 12)]
  158. wall = [(4, 10), (4, 9), (4, 8), (7, 12), (9, 12), (5, 11), (6, 11), (10, 11), (11, 11), (12, 10), (12, 9), (12, 8), (12, 7), (4, 7), (5, 6), (11, 6), (8, 3), (8, 4), (8, 5), (8, 6), (8, 7), (8, 8), (8, 9), (10, 5), (6, 5), (8, 12)]
  159. wallNum = 0
  160. elif hole_type == 10: # 4个C
  161. coordinates = [(5, 4), (6, 4), (10, 4), (11, 4), (12, 5), (12, 6), (9, 10), (9, 11), (5, 9), (6, 9), (4, 10), (4, 11), (5, 12), (6, 12), (12, 10), (12, 11), (11, 12), (10, 12), (10, 7), (11, 7), (7, 6), (7, 5), (4, 5), (4, 6), (10, 9), (7, 10), (6, 7), (9, 6)]
  162. obstacles = [(5, 4), (6, 4), (10, 4), (11, 4), (12, 5), (12, 6), (9, 10), (9, 11), (5, 9), (6, 9), (4, 10), (4, 11), (5, 12), (6, 12), (12, 10), (12, 11), (11, 12), (10, 12), (10, 7), (11, 7), (7, 6), (7, 5), (4, 5), (4, 6), (10, 9), (7, 10), (6, 7), (9, 6)]
  163. wall = [(5, 4), (6, 4), (10, 4), (11, 4), (12, 5), (12, 6), (9, 10), (9, 11), (5, 9), (6, 9), (4, 10), (4, 11), (5, 12), (6, 12), (12, 10), (12, 11), (11, 12), (10, 12), (10, 7), (11, 7), (7, 6), (7, 5), (4, 5), (4, 6), (10, 9), (7, 10), (6, 7), (9, 6)]
  164. wallNum = 0
  165. elif hole_type == 11: # Love
  166. coordinates = [(8, 7), (7, 6), (6, 6), (5, 7), (6, 8), (5, 8), (6, 9), (7, 10), (8, 11), (9, 10), (10, 9), (11, 8), (11, 7), (10, 6), (9, 6), (10, 8), (10, 7), (9, 7), (9, 8), (9, 9), (8, 8), (8, 10), (8, 9), (7, 7), (6, 7), (7, 8), (7, 9)]
  167. obstacles = [(8, 7), (7, 6), (6, 6), (5, 7), (6, 8), (5, 8), (6, 9), (7, 10), (8, 11), (9, 10), (10, 9), (11, 8), (11, 7), (10, 6), (9, 6), (10, 8), (10, 7), (9, 7), (9, 8), (9, 9), (8, 8), (8, 10), (8, 9), (7, 7), (6, 7), (7, 8), (7, 9)]
  168. wall = [(8, 7), (7, 6), (6, 6), (5, 7), (6, 8), (5, 8), (6, 9), (7, 10), (8, 11), (9, 10), (10, 9), (11, 8), (11, 7), (10, 6), (9, 6), (10, 8), (10, 7), (9, 7), (9, 8), (9, 9), (8, 8), (8, 10), (8, 9), (7, 7), (6, 7), (7, 8), (7, 9)]
  169. wallNum = 0
  170. elif hole_type == 12: # I Love QT
  171. coordinates = [(5, 4), (5, 6), (5, 7), (9, 4), (10, 5), (11, 4), (11, 5), (11, 6), (10, 6), (9, 6), (10, 7), (4, 11), (6, 11), (5, 10), (7, 13), (9, 10), (10, 10), (11, 10), (10, 11), (10, 12), (4, 12), (10, 13), (9, 5), (8, 5), (12, 5), (5, 5), (5, 13), (6, 13)]
  172. obstacles = [(5, 4), (5, 6), (5, 7), (9, 4), (10, 5), (11, 4), (11, 5), (11, 6), (10, 6), (9, 6), (10, 7), (4, 11), (6, 11), (5, 10), (7, 13), (9, 10), (10, 10), (11, 10), (10, 11), (10, 12), (4, 12), (10, 13), (9, 5), (8, 5), (12, 5), (5, 5), (5, 13), (6, 13)]
  173. wall = [(5, 4), (5, 6), (5, 7), (9, 4), (10, 5), (11, 4), (11, 5), (11, 6), (10, 6), (9, 6), (10, 7), (4, 11), (6, 11), (5, 10), (7, 13), (9, 10), (10, 10), (11, 10), (10, 11), (10, 12), (4, 12), (10, 13), (9, 5), (8, 5), (12, 5), (5, 5), (5, 13), (6, 13)]
  174. wallNum = 0
  175. elif hole_type == 13: # ICE
  176. coordinates = [(4,6), (4,7), (4,8), (4,9), (4,10), (6,7), (6,8), (6,9), (7,6), (7,10), (8,6), (8,10), (10,6), (10,7), (10,8), (10,9), (10,10), (11,6), (11,8), (11,10), (12,6), (12,8), (12,10)]
  177. obstacles = [(4,6), (4,7), (4,8), (4,9), (4,10), (6,7), (6,8), (6,9), (7,6), (7,10), (8,6), (8,10), (10,6), (10,7), (10,8), (10,9), (10,10), (11,6), (11,8), (11,10), (12,6), (12,8), (12,10)]
  178. wall = [(4,6), (4,7), (4,8), (4,9), (4,10), (6,7), (6,8), (6,9), (7,6), (7,10), (8,6), (8,10), (10,6), (10,7), (10,8), (10,9), (10,10), (11,6), (11,8), (11,10), (12,6), (12,8), (12,10)]
  179. wallNum = 0
  180. else: # 短十字架
  181. coordinates = [[7,8],[8,7],[8,8],[8,9],[9,8]]
  182. obstacles=[[7,8],[8,7],[8,8],[8,9],[9,8]]
  183. wall=[[7,8],[8,7],[8,8],[8,9],[9,8]]
  184. wallNum = 0
  185. wall = setable(wall)
  186. coordinates = setable(coordinates)
  187. else:
  188. obstacles=[]
  189. wall=[]
  190. coordinates=[]
  191. cube=[]
  192. Monsters = randomDistrictAllocation(n, alpha, beta, minDiff, minName, mon_dic, cell_type)[0]
  193. if mon_dic == T.theme3_C_mon_dic: # 实验所特殊设置
  194. if "RogueLabAFireArtillery" not in Monsters and cell_type in ["elite","elite_normal"]:
  195. if len(Monsters) >= 4:
  196. Monsters.append("RogueLabAFireArtillery")
  197. elif mon_dic == T.theme_destiny_mon_dic: # 实验所特殊设置
  198. if len(Monsters) >= 4 and random.randint(1,100) >= 20:
  199. Monsters.append("RogueDestinyATimeStabilizer")
  200. if random.randint(1,100) >= 80:
  201. Monsters.append("RogueDestinyATimeStabilizer")
  202. if R.print_mode:
  203. print(Monsters)
  204. district=[]
  205. for i in range(len(Monsters)):
  206. x = random.randint(3, 13)
  207. y = random.randint(3, 13)
  208. if coordinates.count((x,y)) == 0:
  209. coordinates.append((x,y))
  210. monsters.append([x,y])
  211. district.append({"name": Monsters[i],"y": y,"x": x})
  212. else:
  213. a=x
  214. b=y
  215. while coordinates.count((a,b)) != 0:
  216. a = random.randint(3, 13)
  217. b = random.randint(3, 13)
  218. if coordinates.count((a,b)) == 0:
  219. coordinates.append((a,b))
  220. monsters.append([x,y])
  221. district.append({"name": Monsters[i],"y": b,"x": a})
  222. break
  223. for i in range(len(monsters)):
  224. isStop = random.randint(0, 100)
  225. x = monsters[i][0]
  226. y = monsters[i][1]
  227. if isStop >=100-besiege:
  228. if coordinates.count((x+1,y)) == 0:
  229. if obstacles.count([x+1,y]) == 0:
  230. obstacles.append([x+1,y])
  231. cube.append((x+1, y))
  232. coordinates.append((x+1,y))
  233. if coordinates.count((x-1,y)) == 0:
  234. if obstacles.count([x-1,y]) == 0:
  235. obstacles.append([x-1,y])
  236. cube.append((x-1, y))
  237. coordinates.append((x-1,y))
  238. if coordinates.count((x,y+1)) == 0:
  239. if obstacles.count([x,y+1]) == 0:
  240. obstacles.append([x,y+1])
  241. cube.append((x, y+1))
  242. coordinates.append((x,y+1))
  243. if coordinates.count((x,y-1)) == 0:
  244. if obstacles.count([x,y-1]) == 0:
  245. obstacles.append([x,y-1])
  246. cube.append((x, y-1))
  247. coordinates.append((x,y-1))
  248. while len(wall)<wallNum:
  249. x = random.randint(3, 13)
  250. y = random.randint(3, 13)
  251. if coordinates.count((x,y)) == 0:
  252. if obstacles.count([x,y]) == 0:
  253. obstacles.append((x,y))
  254. wall.append((x, y))
  255. coordinates.append((x,y))
  256. while len(cube)<cubeNum:
  257. x = random.randint(3, 13)
  258. y = random.randint(3, 13)
  259. if coordinates.count((x,y)) == 0:
  260. if obstacles.count([x,y]) == 0:
  261. obstacles.append([x,y])
  262. cube.append((x, y))
  263. coordinates.append((x,y))
  264. # print(wall, cube)
  265. # if len(set(wall).intersection(set(cube))) > 0:
  266. # print("有重复!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!:", set(wall).intersection(set(cube)))
  267. # import sys
  268. # sys.exit() # 中断代码执行
  269. return wall, cube, district
  270. # 子房到实际坐标xy映射
  271. def sub_cell_map(point_list, cell):
  272. if type(point_list) == list:
  273. result = []
  274. for point in point_list:
  275. result.append((point[0]+15*cell[0], point[1]+15*cell[1]))
  276. else:
  277. result = (point_list[0]+15*cell[0], point_list[1]+15*cell[1])
  278. return result
  279. # 实际坐标xy到子房映射
  280. def sub_cell_map_reverse(xy):
  281. return (int((xy[0]-2)/15), int((xy[1]-2)/15))
  282. def dynamic_cube_num(diff):
  283. return int(min(max(20, 0.6*diff), 45))
  284. def random_cell_generate(diff, monster_dic, cell_type, cell):
  285. diff = int(diff * min(1.6, max(0.7, random.normalvariate(1,1))))
  286. wall, cube, district = generalDistrictMapSpawn(diff, 0.7, 8, 5, list(monster_dic.keys())[0], monster_dic, cell_type, 80, 5, dynamic_cube_num(diff))
  287. for mon in district:
  288. new_xy = sub_cell_map((mon["x"], mon["y"]), cell)
  289. mon["x"] = new_xy[0]
  290. mon["y"] = new_xy[1]
  291. final_wall = sub_cell_map(wall, cell)
  292. final_cube = sub_cell_map(cube, cell)
  293. return final_wall, final_cube, district
  294. def generate_xy_symmetric_points(points):
  295. new_points = set() # 使用集合来自动去除重复的点
  296. max_coordinate = 16 # 假设最大坐标为16
  297. for x, y in points:
  298. # 计算x轴和y轴的对称点
  299. symmetric_point_x = (max_coordinate - x, y)
  300. symmetric_point_y = (x, max_coordinate - y)
  301. # 添加原始点和对称点到新集合中,集合自动处理重复值
  302. new_points.add((x, y))
  303. new_points.add(symmetric_point_x)
  304. new_points.add(symmetric_point_y)
  305. # 计算所有点的双轴对称点
  306. for x, y in list(new_points):
  307. symmetric_point_xy = (max_coordinate - x, max_coordinate - y)
  308. new_points.add(symmetric_point_xy)
  309. return list(new_points) # 将集合转换回列表
  310. # xy对称性区域
  311. def xy_SymmetricDistrictMapSpawn(n, alpha, beta, minDiff, minName, mon_dic, cell_type, besiege, wallNum, cubeNum, level_num):
  312. # 前几个参数和分区函数相同
  313. # besiege表示每个怪物被墙围住的概率%(0-100)
  314. # wallNum, cubeANum, cubeBNum为三种障碍物的最大上限数量(一般wallNum=5, 15<cubeNum<64)
  315. # wall为不可摧毁墙;
  316. monsters = []
  317. small_monsters = []
  318. obstacles=[]
  319. wall=[]
  320. coordinates=[]
  321. cube=[]
  322. district=[]
  323. if R.difficulty == "Easy":
  324. l_bound = 3
  325. elif R.difficulty == "Normal":
  326. l_bound = 2
  327. else:
  328. l_bound = 1
  329. sym_type = "corner"
  330. if random.randint(1,100)>=30:
  331. if random.randint(1,100)>=50:
  332. sym_type = "axis"
  333. else:
  334. sym_type = "centre"
  335. if sym_type == "corner":
  336. if R.difficulty == "Easy" and cell_type == "elite":
  337. cell_type = "normal_elite"
  338. if R.difficulty == "Easy" and (level_num - 1) % 5 + 1 <= 2:
  339. cell_type = "normal"
  340. Monsters = []
  341. smallMonsters = randomDistrictAllocation(n, alpha, beta, minDiff, minName, mon_dic, cell_type, symmetric=True)[0]
  342. smallMonsters = smallMonsters[1:max(2,min(3,len(smallMonsters)+1))]
  343. elif sym_type == "axis":
  344. Monsters = [random.choice(randomDistrictAllocation(n, alpha, beta, minDiff, minName, mon_dic, cell_type="elite", symmetric=True)[0])]
  345. if (level_num - 1) % 5 + 1 <= l_bound:
  346. smallMonsters = randomDistrictAllocation(n, alpha, beta, minDiff, minName, mon_dic, cell_type="normal", symmetric=True)[0]
  347. else:
  348. if R.difficulty == "Easy" and cell_type == "elite":
  349. cell_type = "normal_elite"
  350. if R.difficulty == "Easy" and (level_num - 1) % 5 + 1 <= 2:
  351. cell_type = "normal"
  352. smallMonsters = randomDistrictAllocation(n, alpha, beta, minDiff, minName, mon_dic, cell_type, symmetric=True)[0]
  353. if cell_type == "normal":
  354. smallMonsters = smallMonsters[1:max(2,min(3,len(smallMonsters)+1))]
  355. else:
  356. smallMonsters = [smallMonsters[0]]
  357. (x,y) = random.choice([(5,8),(6,8),(7,8),(7,8),(8,7),(8,7),(8,6),(8,5)])
  358. sym_points = generate_xy_symmetric_points([(x,y)])
  359. for point in sym_points:
  360. coordinates.append((point[0],point[1]))
  361. monsters.append([point[0],point[1]])
  362. district.append({"name": Monsters[0],"y": point[1],"x": point[0]})
  363. if coordinates.count((point[0]+1,point[1])) == 0:
  364. if obstacles.count([point[0]+1,point[1]]) == 0:
  365. obstacles.append([point[0]+1,point[1]])
  366. cube.append((point[0]+1,point[1]))
  367. coordinates.append((point[0]+1,point[1]))
  368. if coordinates.count((point[0]-1,point[1])) == 0:
  369. if obstacles.count([point[0]-1,point[1]]) == 0:
  370. obstacles.append([point[0]-1,point[1]])
  371. cube.append((point[0]-1,point[1]))
  372. coordinates.append((point[0]-1,point[1]))
  373. if coordinates.count((point[0],point[1]+1)) == 0:
  374. if obstacles.count([point[0],point[1]+1]) == 0:
  375. obstacles.append([point[0],point[1]+1])
  376. cube.append((point[0],point[1]+1))
  377. coordinates.append((point[0],point[1]+1))
  378. if coordinates.count((point[0],point[1]-1)) == 0:
  379. if obstacles.count([point[0],point[1]-1]) == 0:
  380. obstacles.append([point[0],point[1]-1])
  381. cube.append((point[0],point[1]-1))
  382. coordinates.append((point[0],point[1]-1))
  383. else:
  384. Monsters = [random.choice(randomDistrictAllocation(n, alpha, beta, minDiff, minName, mon_dic, cell_type="elite", symmetric=True)[0])]
  385. if mon_dic == T.theme3_C_mon_dic: # 实验所特殊设置
  386. if "RogueLabAFireArtillery" not in Monsters and cell_type in ["elite","elite_normal"]:
  387. Monsters = ["RogueLabAFireArtillery"]
  388. if (level_num - 1) % 5 + 1 <= l_bound:
  389. smallMonsters = randomDistrictAllocation(n, alpha, beta, minDiff, minName, mon_dic, cell_type="normal", symmetric=True)[0]
  390. else:
  391. if R.difficulty == "Easy" and cell_type == "elite":
  392. cell_type = "normal_elite"
  393. if R.difficulty == "Easy" and (level_num - 1) % 5 + 1 <= 2:
  394. cell_type = "normal"
  395. smallMonsters = randomDistrictAllocation(n, alpha, beta, minDiff, minName, mon_dic, cell_type, symmetric=True)[0]
  396. if cell_type == "normal":
  397. smallMonsters = smallMonsters[0:max(2,min(3,len(smallMonsters)+1))-1]
  398. if R.difficulty == "Easy" and len(smallMonsters) > 0:
  399. smallMonsters = [smallMonsters[0]]
  400. else:
  401. smallMonsters = [smallMonsters[0]]
  402. coordinates.append((8,8))
  403. monsters.append([8,8])
  404. district.append({"name": Monsters[0],"y": 8,"x": 8})
  405. # print(sym_type, Monsters, smallMonsters)
  406. # print(cell_type, (level_num - 1) % 5 + 1, l_bound)
  407. for i in range(len(smallMonsters)):
  408. x = random.choice([5,6,6,7,7,7])
  409. y = random.choice([5,6,6,7,7,7])
  410. if coordinates.count((x,y)) == 0:
  411. coordinates.append((x,y))
  412. monsters.append([x,y])
  413. small_monsters.append([x,y])
  414. district.append({"name": smallMonsters[i],"y": y,"x": x})
  415. else:
  416. a=x
  417. b=y
  418. t = 0
  419. while coordinates.count((a,b)) != 0:
  420. t += 1
  421. if t >= 10000:
  422. break
  423. a = random.choice([5,6,6,7,7,7])
  424. b = random.choice([5,6,6,7,7,7])
  425. if coordinates.count((a,b)) == 0:
  426. coordinates.append((a,b))
  427. monsters.append([a,b])
  428. small_monsters.append([a,b])
  429. district.append({"name": smallMonsters[i],"y": b,"x": a})
  430. break
  431. for i in range(len(monsters)):
  432. isStop = random.randint(0, 100)
  433. x = monsters[i][0]
  434. y = monsters[i][1]
  435. if isStop >= 0:
  436. if coordinates.count((x+1,y)) == 0:
  437. if obstacles.count([x+1,y]) == 0:
  438. obstacles.append([x+1,y])
  439. cube.append((x+1, y))
  440. coordinates.append((x+1,y))
  441. if coordinates.count((x-1,y)) == 0:
  442. if obstacles.count([x-1,y]) == 0:
  443. obstacles.append([x-1,y])
  444. cube.append((x-1, y))
  445. coordinates.append((x-1,y))
  446. if coordinates.count((x,y+1)) == 0:
  447. if obstacles.count([x,y+1]) == 0:
  448. obstacles.append([x,y+1])
  449. cube.append((x, y+1))
  450. coordinates.append((x,y+1))
  451. if coordinates.count((x,y-1)) == 0:
  452. if obstacles.count([x,y-1]) == 0:
  453. obstacles.append([x,y-1])
  454. cube.append((x, y-1))
  455. coordinates.append((x,y-1))
  456. while len(wall)<int(wallNum/3):
  457. x = random.randint(3, 8)
  458. y = random.randint(3, 8)
  459. if coordinates.count((x,y)) == 0:
  460. if obstacles.count([x,y]) == 0:
  461. obstacles.append([x,y])
  462. wall.append((x, y))
  463. coordinates.append((x,y))
  464. while len(cube)<int(cubeNum/3):
  465. x = random.randint(3, 8)
  466. y = random.randint(3, 8)
  467. if coordinates.count((x,y)) == 0:
  468. if obstacles.count([x,y]) == 0:
  469. obstacles.append([x,y])
  470. cube.append((x, y))
  471. coordinates.append((x,y))
  472. res_cube = generate_xy_symmetric_points(cube)
  473. res_wall = generate_xy_symmetric_points(wall)
  474. for monster in district:
  475. for p in generate_xy_symmetric_points([(monster["x"],monster["y"])]):
  476. if {"name": monster["name"],"y": p[1],"x": p[0]} not in district and (p[0],p[1]) not in coordinates:
  477. coordinates.append((p[0],p[1]))
  478. district.append({"name": monster["name"],"y": p[1],"x": p[0]})
  479. return res_wall, res_cube, district
  480. def xy_symmetric_cell_generate(diff, monster_dic, cell_type, cell, level_num):
  481. diff = int(diff * min([2, max(0.7, random.normalvariate(1,1))]))
  482. wall, cube, district = xy_SymmetricDistrictMapSpawn(diff, 0.7, 8, 5, list(monster_dic.keys())[0], monster_dic, cell_type, 80, 5, dynamic_cube_num(diff), level_num)
  483. for mon in district:
  484. new_xy = sub_cell_map((mon["x"], mon["y"]), cell)
  485. mon["x"] = new_xy[0]
  486. mon["y"] = new_xy[1]
  487. final_wall = sub_cell_map(wall, cell)
  488. final_cube = sub_cell_map(cube, cell)
  489. return final_wall, final_cube, district
  490. def generate_rotated_points(points):
  491. new_points = set() # 使用集合来自动去除重复的点
  492. cx, cy = 8, 8 # 旋转中心
  493. for x, y in points:
  494. # 原始点
  495. new_points.add((x, y))
  496. # 90度旋转
  497. x_90 = cy - (y - cy)
  498. y_90 = (x - cx) + cy
  499. new_points.add((x_90, y_90))
  500. # 180度旋转
  501. x_180 = cx - (x - cx)
  502. y_180 = cy - (y - cy)
  503. new_points.add((x_180, y_180))
  504. # 270度旋转
  505. x_270 = (y - cy) + cx
  506. y_270 = cy - (x - cx)
  507. new_points.add((x_270, y_270))
  508. return list(new_points) # 将集合转换回列表
  509. # 旋转对称区域
  510. def rotationalSymmetricDistrictMapSpawn(n, alpha, beta, minDiff, minName, mon_dic, cell_type, besiege, wallNum, cubeNum, level_num):
  511. # 前几个参数和分区函数相同
  512. # besiege表示每个怪物被墙围住的概率%(0-100)
  513. # wallNum, cubeANum, cubeBNum为三种障碍物的最大上限数量(一般wallNum=5, 15<cubeNum<64)
  514. # wall为不可摧毁墙;
  515. monsters = []
  516. small_monsters = []
  517. obstacles=[]
  518. wall=[]
  519. coordinates=[]
  520. cube=[]
  521. district=[]
  522. if R.difficulty == "Easy":
  523. l_bound = 3
  524. elif R.difficulty == "Normal":
  525. l_bound = 2
  526. else:
  527. l_bound = 1
  528. sym_type = "corner"
  529. if random.randint(1,100)>=50:
  530. sym_type = "centre"
  531. if sym_type == "corner":
  532. if R.difficulty == "Easy" and cell_type == "elite":
  533. cell_type = "normal_elite"
  534. if R.difficulty == "Easy" and (level_num - 1) % 5 + 1 <= 2:
  535. cell_type = "normal"
  536. Monsters = []
  537. smallMonsters = [random.choice(randomDistrictAllocation(n, alpha, beta, minDiff, minName, mon_dic, cell_type, symmetric=True)[0])] + [random.choice(randomDistrictAllocation(n, alpha, beta, minDiff, minName, mon_dic, "normal", symmetric=True)[0])]
  538. else:
  539. Monsters = [random.choice(randomDistrictAllocation(n, alpha, beta, minDiff, minName, mon_dic, cell_type="elite", symmetric=True)[0])]
  540. if (level_num - 1) % 5 + 1 <= l_bound:
  541. smallMonsters = [random.choice(randomDistrictAllocation(n, alpha, beta, minDiff, minName, mon_dic, cell_type="normal", symmetric=True)[0])] + random.randint(0,1) * [random.choice(randomDistrictAllocation(n, alpha, beta, minDiff, minName, mon_dic, cell_type="normal", symmetric=True)[0])]
  542. else:
  543. if R.difficulty == "Easy" and cell_type == "elite":
  544. cell_type = "normal_elite"
  545. if R.difficulty == "Easy" and (level_num - 1) % 5 + 1 <= 2:
  546. cell_type = "normal"
  547. smallMonsters = [random.choice(randomDistrictAllocation(n, alpha, beta, minDiff, minName, mon_dic, cell_type=cell_type, symmetric=True)[0])] + random.randint(0,1) * [random.choice(randomDistrictAllocation(n, alpha, beta, minDiff, minName, mon_dic, cell_type="normal", symmetric=True)[0])]
  548. coordinates.append((8,8))
  549. monsters.append([8,8])
  550. district.append({"name": Monsters[0],"y": 8,"x": 8})
  551. if R.print_mode:
  552. print(sym_type, Monsters, smallMonsters)
  553. print(cell_type, (level_num - 1) % 5 + 1, l_bound)
  554. for i in range(len(smallMonsters)):
  555. x = random.choice([5,6,6,7,7,7])
  556. y = random.choice([5,6,6,7,7,7])
  557. if coordinates.count((x,y)) == 0:
  558. coordinates.append((x,y))
  559. monsters.append([x,y])
  560. small_monsters.append([x,y])
  561. district.append({"name": smallMonsters[i],"y": y,"x": x})
  562. else:
  563. a=x
  564. b=y
  565. t = 0
  566. while coordinates.count((a,b)) != 0:
  567. t += 1
  568. if t >= 10000:
  569. break
  570. a = random.choice([5,6,6,7,7,7])
  571. b = random.choice([5,6,6,7,7,7])
  572. if coordinates.count((a,b)) == 0:
  573. coordinates.append((a,b))
  574. monsters.append([a,b])
  575. small_monsters.append([a,b])
  576. district.append({"name": smallMonsters[i],"y": b,"x": a})
  577. break
  578. for i in range(len(monsters)):
  579. isStop = random.randint(0, 100)
  580. x = monsters[i][0]
  581. y = monsters[i][1]
  582. if isStop >= 0:
  583. if coordinates.count((x+1,y)) == 0:
  584. if obstacles.count([x+1,y]) == 0:
  585. obstacles.append([x+1,y])
  586. cube.append((x+1, y))
  587. coordinates.append((x+1,y))
  588. if coordinates.count((x-1,y)) == 0:
  589. if obstacles.count([x-1,y]) == 0:
  590. obstacles.append([x-1,y])
  591. cube.append((x-1, y))
  592. coordinates.append((x-1,y))
  593. if coordinates.count((x,y+1)) == 0:
  594. if obstacles.count([x,y+1]) == 0:
  595. obstacles.append([x,y+1])
  596. cube.append((x, y+1))
  597. coordinates.append((x,y+1))
  598. if coordinates.count((x,y-1)) == 0:
  599. if obstacles.count([x,y-1]) == 0:
  600. obstacles.append([x,y-1])
  601. cube.append((x, y-1))
  602. coordinates.append((x,y-1))
  603. while len(wall)<int(wallNum/3):
  604. x = random.randint(3, 8)
  605. y = random.randint(3, 8)
  606. if coordinates.count((x,y)) == 0:
  607. if obstacles.count([x,y]) == 0:
  608. obstacles.append([x,y])
  609. wall.append((x, y))
  610. coordinates.append((x,y))
  611. while len(cube)<int(cubeNum/3):
  612. x = random.randint(3, 8)
  613. y = random.randint(3, 8)
  614. if coordinates.count((x,y)) == 0:
  615. if obstacles.count([x,y]) == 0:
  616. obstacles.append([x,y])
  617. cube.append((x, y))
  618. coordinates.append((x,y))
  619. res_cube = generate_rotated_points(cube)
  620. res_wall = generate_rotated_points(wall)
  621. res_wall = list(set(res_wall) - set(res_cube))
  622. for monster in district:
  623. for p in generate_rotated_points([(monster["x"],monster["y"])]):
  624. if {"name": monster["name"],"y": p[1],"x": p[0]} not in district and (p[0],p[1]) not in coordinates:
  625. coordinates.append((p[0],p[1]))
  626. district.append({"name": monster["name"],"y": p[1],"x": p[0]})
  627. return res_wall, res_cube, district
  628. def rotationalSymmetric_cell_generate(diff, monster_dic, cell_type, cell, level_num):
  629. diff = int(diff * min([2, max(0.7, random.normalvariate(1,1))]))
  630. wall, cube, district = rotationalSymmetricDistrictMapSpawn(diff, 0.7, 8, 5, list(monster_dic.keys())[0], monster_dic, cell_type, 80, 5, dynamic_cube_num(diff), level_num)
  631. for mon in district:
  632. new_xy = sub_cell_map((mon["x"], mon["y"]), cell)
  633. mon["x"] = new_xy[0]
  634. mon["y"] = new_xy[1]
  635. final_wall = sub_cell_map(wall, cell)
  636. final_cube = sub_cell_map(cube, cell)
  637. return final_wall, final_cube, district
  638. def bossDistrictMapSpawn(n, alpha, beta, minDiff, minName, mon_dic, cell_type, besiege, wallNum, cubeNum):
  639. # 前几个参数和分区函数相同
  640. # besiege表示每个怪物被墙围住的概率%(0-100)
  641. # wallNum, cubeANum, cubeBNum为三种障碍物的最大上限数量(一般wallNum=5, 15<cubeNum<64)
  642. # wall为不可摧毁墙;
  643. monsters = []
  644. cell_type = random.choice(["single_boss","mix_boss"])
  645. if random.randint(1, 100) >= 95:
  646. hole_type = random.randint(1,5)
  647. if hole_type == 1:
  648. coordinates = [[7,7],[7,8],[7,9],[8,7],[8,8],[8,9],[9,7],[9,8],[9,9]]
  649. obstacles=[[7,7],[7,8],[7,9],[8,7],[8,8],[8,9],[9,7],[9,8],[9,9]]
  650. wall=[[7,7],[7,8],[7,9],[8,7],[8,8],[8,9],[9,7],[9,8],[9,9]]
  651. wallNum = 0
  652. elif hole_type == 2:
  653. coordinates = [[7,7],[7,8],[7,9],[8,7],[8,8],[8,9],[9,7],[9,8],[9,9],[6,8],[8,6],[8,10],[10,8]]
  654. obstacles=[[7,7],[7,8],[7,9],[8,7],[8,8],[8,9],[9,7],[9,8],[9,9],[6,8],[8,6],[8,10],[10,8]]
  655. wall=[[7,7],[7,8],[7,9],[8,7],[8,8],[8,9],[9,7],[9,8],[9,9],[6,8],[8,6],[8,10],[10,8]]
  656. wallNum = 0
  657. elif hole_type == 3:
  658. coordinates = [[6,7],[7,6],[7,7], [9,6],[9,7],[10,7], [6,9],[7,9],[7,10], [9,9],[9,10],[10,9]]
  659. obstacles = [[6,7],[7,6],[7,7], [9,6],[9,7],[10,7], [6,9],[7,9],[7,10], [9,9],[9,10],[10,9]]
  660. wall = [[6,7],[7,6],[7,7], [9,6],[9,7],[10,7], [6,9],[7,9],[7,10], [9,9],[9,10],[10,9]]
  661. wallNum = 0
  662. elif hole_type == 4:
  663. coordinates = [[5,7],[5,9],[6,6],[6,10],[7,5],[7,11],[11,7],[11,9],[10,6],[10,10],[9,5],[9,11]]
  664. obstacles = [[5,7],[5,9],[6,6],[6,10],[7,5],[7,11],[11,7],[11,9],[10,6],[10,10],[9,5],[9,11]]
  665. wall = [[5,7],[5,9],[6,6],[6,10],[7,5],[7,11],[11,7],[11,9],[10,6],[10,10],[9,5],[9,11]]
  666. wallNum = 0
  667. else:
  668. coordinates = [[7,8],[8,7],[8,8],[8,9],[9,8]]
  669. obstacles=[[7,8],[8,7],[8,8],[8,9],[9,8]]
  670. wall=[[7,8],[8,7],[8,8],[8,9],[9,8]]
  671. wallNum = 0
  672. coordinates = setable(coordinates)
  673. else:
  674. obstacles=[]
  675. wall=[]
  676. coordinates=[]
  677. cube=[]
  678. Monsters = randomDistrictAllocation(n, alpha, beta, minDiff, minName, mon_dic, cell_type)[0]
  679. boss_num = 0
  680. for m in Monsters:
  681. if m in T.boss_list:
  682. boss_num += 1
  683. if boss_num >= 3:
  684. Monsters.remove(m)
  685. if R.print_mode:
  686. print(Monsters)
  687. district=[]
  688. for i in range(len(Monsters)):
  689. x = random.randint(3, 13)
  690. y = random.randint(3, 13)
  691. if coordinates.count((x,y)) == 0:
  692. coordinates.append((x,y))
  693. monsters.append([x,y])
  694. district.append({"name": Monsters[i],"y": y,"x": x})
  695. else:
  696. a=x
  697. b=y
  698. while coordinates.count((a,b)) != 0:
  699. a = random.randint(3, 13)
  700. b = random.randint(3, 13)
  701. if coordinates.count((a,b)) == 0:
  702. coordinates.append((a,b))
  703. monsters.append([x,y])
  704. district.append({"name": Monsters[i],"y": b,"x": a})
  705. break
  706. for i in range(len(monsters)):
  707. isStop = random.randint(0, 100)
  708. x = monsters[i][0]
  709. y = monsters[i][1]
  710. if isStop >=100-besiege:
  711. if coordinates.count((x+1,y)) == 0:
  712. if obstacles.count((x+1,y)) == 0:
  713. obstacles.append([x+1,y])
  714. cube.append((x+1, y))
  715. coordinates.append((x+1,y))
  716. if coordinates.count((x-1,y)) == 0:
  717. if obstacles.count([x-1,y]) == 0:
  718. obstacles.append([x-1,y])
  719. cube.append((x-1, y))
  720. coordinates.append((x-1,y))
  721. if coordinates.count((x,y+1)) == 0:
  722. if obstacles.count([x,y+1]) == 0:
  723. obstacles.append([x,y+1])
  724. cube.append((x, y+1))
  725. coordinates.append((x,y+1))
  726. if coordinates.count((x,y-1)) == 0:
  727. if obstacles.count([x,y-1]) == 0:
  728. obstacles.append([x,y-1])
  729. cube.append((x, y-1))
  730. coordinates.append((x,y-1))
  731. while len(wall)<wallNum:
  732. x = random.randint(3, 13)
  733. y = random.randint(3, 13)
  734. if coordinates.count((x,y)) == 0:
  735. if obstacles.count([x,y]) == 0:
  736. obstacles.append([x,y])
  737. wall.append((x, y))
  738. coordinates.append((x,y))
  739. while len(cube)<cubeNum:
  740. x = random.randint(3, 13)
  741. y = random.randint(3, 13)
  742. if coordinates.count((x,y)) == 0:
  743. if obstacles.count([x,y]) == 0:
  744. obstacles.append([x,y])
  745. cube.append((x, y))
  746. coordinates.append((x,y))
  747. return wall, cube, district
  748. def boss_cell_generate(diff, monster_dic, cell_type, cell):
  749. diff = int(diff * min(1.6, max(0.8, random.normalvariate(1,1))))
  750. wall, cube, district = bossDistrictMapSpawn(diff, 0.7, 8, 5, list(monster_dic.keys())[0], monster_dic, cell_type, 80, 5, dynamic_cube_num(diff))
  751. for mon in district:
  752. new_xy = sub_cell_map((mon["x"], mon["y"]), cell)
  753. mon["x"] = new_xy[0]
  754. mon["y"] = new_xy[1]
  755. final_wall = sub_cell_map(wall, cell)
  756. final_cube = sub_cell_map(cube, cell)
  757. return final_wall, final_cube, district
  758. # 商店区
  759. def shop_cell_generate(cell, shop_level=1, level_num=1):
  760. # wall = [(5,5),(4,5),(3,5),(3,6),(3,7),(3,8),(3,9), (4,9), (5,6),(5,7),(5,9),(5,11),(5,12),(5,13), (6,5),(6,6),(6,7),(6,13), (7,5),(7,9),(7,10),(7,11),(7,13), (8,4),(8,5),(8,6),(8,7),(8,9),(8,13), (9,4),(9,9),(9,10),(9,11),(9,13), (10,4),(10,5),(10,6),(10,7),(10,13), (11,5),(11,9),(11,11),(11,12),(11,13), (12,5),(12,6),(12,7),(12,8),(12,9)]
  761. # sell_coordinate = [(5,5),(11,5),(5,11),(11,11)]
  762. # district = [{"name": "RougeShopQuit","y": 10,"x": 8}]
  763. wall = [(12, 5), (12, 6), (4, 5), (4, 10), (4, 11), (6, 12), (7, 12), (10, 12), (11, 12), (12, 12), (12, 11), (12, 10), (12, 9), (12, 4), (11, 4), (4, 6), (4, 7), (10, 4), (4, 12), (5, 12), (6, 5), (5, 10), (10, 11), (6, 7), (6, 6), (10, 6), (10, 10), (8, 4), (8, 5), (10, 7), (8, 7), (6, 8), (4, 8), (10, 5), (12, 7), (7, 10), (6, 10), (10, 9), (8, 12), (8, 6), (5, 5), (7, 4), (6, 4), (8, 10), (8, 8), (4, 4), (5, 4)]
  764. sell_coordinate = [(5,6),(11,5),(5,11),(11,11)]
  765. district = [{"name": "RougeShopQuit","y": 5,"x": 7}]
  766. seller_1 = ["RougeShopHP100", "RougeShopDMG100", "RougeSmallHPRecoveryPotion", "RougeSmallHPRecoveryPotion", "RougeSmallHPRecoveryPotion", "RougeShopMonsterDefenseN200", "RougeShopMonsterHPN4", "RougeShopHPReviveCard", "RougeShopFlameSelfDMGN20"]
  767. seller_2 = ["RougeShopHP100", "RougeShopHP200", "RougeShopDMG100", "RougeShopDMG200", "RougeSmallHPRecoveryPotion", "RougeSmallHPRecoveryPotion", "RougeSmallHPRecoveryPotionMiddle", "RougeSmallHPRecoveryPotionMiddle", "RougeShopMonsterDefenseN200", "RougeShopMonsterDefenseN400", "RougeShopMonsterHPN4", "RougeShopMonsterHPN8", "RougeShopHPReviveCard", "RougeShopHPReviveCard", "RougeShopFlameSelfDMGN20", "RougeShopFlameSelfDMGN40", "RougeShopSwitchHPDMG", "RougeShopSlowImmune", "RougeShopReverseImmune", "RougeShopRootImmune", "RougeShopStunImmune", "RougeShopDestination"]
  768. seller_3 = ["RougeShopHP100", "RougeShopHP200", "RougeShopHP300", "RougeShopDMG100", "RougeShopDMG200", "RougeShopDMG300", "RougeSmallHPRecoveryPotion", "RougeSmallHPRecoveryPotion", "RougeSmallHPRecoveryPotionMiddle", "RougeSmallHPRecoveryPotionMiddle", "RougeSmallHPRecoveryPotionBig", "RougeSmallHPRecoveryPotionBig", "RougeSmallHPRecoveryPotionBig", "RougeShopMonsterDefenseN200", "RougeShopMonsterDefenseN400", "RougeShopMonsterDefenseN800", "RougeShopMonsterHPN4", "RougeShopMonsterHPN8", "RougeShopMonsterHPN16", "RougeShopHPReviveCard", "RougeShopHPReviveCard", "RougeShopHPReviveCard", "RougeShopFlameSelfDMGN20", "RougeShopFlameSelfDMGN40", "RougeShopFlameSelfDMGN60", "RougeShopSwitchHPDMG", "RougeShopSlowImmune", "RougeShopReverseImmune", "RougeShopRootImmune", "RougeShopStunImmune"] + \
  769. ["RougeShopDestination"]
  770. seller_4 = ["RougeShopHP300", "RougeShopDMG300", "RougeSmallHPRecoveryPotionBig", "RougeShopMonsterHPN16", "RougeShopHPReviveCard", "RougeShopFlameSelfDMGN60", "RougeShopSwitchHPDMG", "RougeShopSlowImmune", "RougeShopReverseImmune", "RougeShopRootImmune", "RougeShopStunImmune", "RougeShopDestination"]
  771. seller_5 = seller_4 # 巫术商店(用血量来买伤害/道具/金币)
  772. sell_num = random.randint(3,4)
  773. if shop_level==3:
  774. if random.randint(1,100)>=90:
  775. shop_level = 4
  776. sell_num = random.randint(3,4)
  777. if shop_level<=3:
  778. if random.randint(1,100)>=95:
  779. shop_level = 5
  780. sell_num = 4
  781. for i in range(sell_num):
  782. if shop_level==1:
  783. s = random.choice(seller_1)
  784. elif shop_level==2:
  785. s = random.choice(seller_2)
  786. elif shop_level==3:
  787. s = random.choice(seller_3)
  788. elif shop_level==4:
  789. s = random.choice(seller_4)
  790. else:
  791. s = random.choice(seller_5)
  792. if i == 0 and not R.has_ocean_shop:
  793. if R.pass_status[R.difficulty] >= 1 and level_num >= 8 and not R.story_ocean:
  794. R.has_ocean_shop = True
  795. s = "RougeStoryOcean"
  796. if R.print_mode:
  797. print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
  798. print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
  799. print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
  800. print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
  801. print("yes!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", level_num)
  802. # Test
  803. # s = "RougeShopReverseImmune"
  804. xy = sell_coordinate[i]
  805. district.append({"name": s, "y": xy[1], "x": xy[0]})
  806. for mon in district:
  807. new_xy = sub_cell_map((mon["x"], mon["y"]), cell)
  808. mon["x"] = new_xy[0]
  809. mon["y"] = new_xy[1]
  810. final_wall = sub_cell_map(wall, cell)
  811. return final_wall, district
  812. # 祈运区
  813. def treasure_cell_generate(cell, shop_level=1):
  814. wall1 = [(5,5),(5,6),(6,5),(6,8),(6,9),(7,9),(7,10),(8,6),(8,10),(9,6),(9,7),(10,7),(10,8),(10,11),(11,10),(11,11)]
  815. wall2 = [(10, 7), (10, 9), (6, 9), (6, 7), (7, 6), (9, 6), (9, 10), (7, 10), (9, 5), (8, 4), (7, 11), (8, 12), (11, 9), (12, 8), (5, 7), (4, 8), (9, 12), (4, 9), (12, 7), (7, 4)]
  816. wall3 = [(5, 6), (6, 5), (10, 11), (2, 6), (6, 2), (11, 10), (14, 10), (10, 14), (6, 9), (7, 10), (7, 11), (5, 9), (7, 9), (9, 5), (9, 6), (9, 7), (10, 7), (11, 7), (3, 12), (3, 13), (4, 13), (12, 3), (13, 3), (13, 4), (10, 12), (12, 10), (4, 6), (6, 4), (10, 10), (6, 6), (7, 7), (9, 9), (9, 10), (7, 6), (8, 12), (7, 12), (9, 4), (8, 4), (12, 7), (12, 8), (4, 8), (4, 9)]
  817. wall = random.choice([wall1, wall2, wall3])
  818. cube = [(4,10),(4,11),(4,12),(5,10),(5,12),(6,10),(6,11),(6,12), (10,4),(10,5),(10,6),(11,4),(11,6),(12,4),(12,5),(12,6)]
  819. district = [{"name": "RougeTreasureController","y": 8,"x": 8}]
  820. for mon in district:
  821. new_xy = sub_cell_map((mon["x"], mon["y"]), cell)
  822. mon["x"] = new_xy[0]
  823. mon["y"] = new_xy[1]
  824. final_wall = sub_cell_map(wall, cell)
  825. final_cube = sub_cell_map(cube, cell)
  826. return final_wall, final_cube, district
  827. # 擂台区
  828. def combat_decision(cell, level_num):
  829. wall = [(4,12),(12,4), (10, 4), (11, 4), (12, 5), (12, 6), (5, 9), (4, 10), (4, 11), (5, 12), (6, 12), (11, 7), (9, 5), (7, 11), (8, 7), (8, 9), (7, 10), (9, 6), (5, 3), (3, 5), (4, 4), (5, 5), (11, 13), (13, 11), (11, 11), (12, 12)]
  830. cube = [(4, 3), (3, 4), (6, 4), (6, 5), (5, 6), (4, 6), (8, 8), (12, 10), (11, 10), (10, 11), (10, 12), (12, 13), (13, 12)]
  831. district = [{"name": "RougeCombatAccept","y": 5,"x": 11},{"name": "RougeCombatRun","y": 11,"x": 5}]
  832. # print(R.pass_status[R.difficulty], level_num, R.story_eden, R.story_destiny)
  833. if R.pass_status[R.difficulty] >= 1 and level_num == 10 and not R.story_eden and not R.story_destiny:
  834. # print("comem on!")
  835. R.story_eden = True
  836. district = [{"name": "RougeStoryEden","y": 5,"x": 11},{"name": "RougeStoryRun","y": 11,"x": 5}]
  837. # 坐标映射
  838. for mon in district:
  839. new_xy = sub_cell_map((mon["x"], mon["y"]), cell)
  840. mon["x"] = new_xy[0]
  841. mon["y"] = new_xy[1]
  842. final_wall = sub_cell_map(wall, cell)
  843. final_cube = sub_cell_map(cube, cell)
  844. return final_wall, final_cube, district
  845. # 赌场
  846. def casino(cell):
  847. wall = [(4, 4), (5, 4), (4, 5), (4, 6), (4, 7), (6, 7), (6, 6), (7, 6), (11, 4), (12, 4), (12, 5), (12, 6), (12, 7), (9, 6), (10, 6), (10, 7), (12, 9), (12, 10), (12, 11), (12, 12), (11, 12), (10, 12), (9, 12), (10, 9), (10, 10), (9, 10), (6, 9), (6, 10), (7, 10), (4, 9), (4, 10), (4, 11), (4, 12), (5, 12), (6, 12), (7, 12), (6, 4), (10, 4), (9, 4), (7, 4), (7, 7), (7, 9), (9, 7), (9, 9)]
  848. cube = [(8, 7), (7, 8), (9, 8), (8, 9)]
  849. district = [{"name": "RougeCasinoGamble20P","y": 5,"x": 11},{"name": "RougeCasinoRun","y": 8,"x": 8}]
  850. # 坐标映射
  851. for mon in district:
  852. new_xy = sub_cell_map((mon["x"], mon["y"]), cell)
  853. mon["x"] = new_xy[0]
  854. mon["y"] = new_xy[1]
  855. final_wall = sub_cell_map(wall, cell)
  856. final_cube = sub_cell_map(cube, cell)
  857. return final_wall, final_cube, district