import random import game.const.game as G import game.const.rouge as R import game.const.rouge_theme as T def randomDistrictAllocation(n, alpha, beta, minDiff, minName, mon_dic, cell_type, symmetric=False): # 其中n为该区难度 # alpha为第二只及以上的重复怪物的权重系数,取值范围(0,1),通常为0.5 # beta为怪的随机变难因子(容忍最后加的这只怪最终超出地图难度多少) ( max{单怪难度+剩余可分配难度}=beta ),通常为8 # minDiff为进行随机抽取的最低剩余可分配难度,当剩余难度比此值低时则强制选取1只怪,通常为3 # minName为字符串:"**",即强制选取的怪物名称 break_time = 0 district=[] diffList=[] # 初始化三个空的列表,用于存储不同类型的主键 normal_keys = [] elite_keys = [] boss_keys = [] normal_elite_keys = [] elite_boss_keys = [] all_keys = [] has_boss = False # 遍历原始字典,根据"type"字段分类主键 for key, value in mon_dic.items(): if value['type'] == 'normal': normal_keys.append(key) normal_elite_keys.append(key) all_keys.append(key) elif value['type'] == 'elite': elite_keys.append(key) normal_elite_keys.append(key) elite_boss_keys.append(key) all_keys.append(key) elif value['type'] == 'boss': boss_keys.append(key) elite_boss_keys.append(key) all_keys.append(key) if cell_type == "single_boss" or cell_type == "mix_boss": n = int(n*1.2) if R.difficulty == "Easy": rd = random.randint(0,1) elif R.difficulty == "Normal": rd = random.randint(-1,1) else: rd = random.randint(-2,1) while sum(diffList) < n: name = None break_time += 1 if len(district) > 5-random.randint(0,1): break else: if R.difficulty == "Easy" and len(district) > 4-random.randint(0,1): break if cell_type == "elite": if len(district) > R.diff_elite_num[R.difficulty]-rd: break if cell_type == "elite_normal": if len(district) > R.diff_elite_normal_num[R.difficulty]-rd: break if break_time >= 10000: if cell_type == "single_boss" or "mix_boss": name = random.choice(normal_elite_keys) district.append(name) diffList.append(mon_dic[name]["diff"]) else: district.append(minName) diffList.append(minDiff) break # 开始分怪 if cell_type == "normal": name = random.choice(normal_keys) if cell_type == "normal_elite": name = random.choice(normal_elite_keys) if cell_type == "elite": name = random.choice(elite_keys) if cell_type == "single_boss": name = random.choice(boss_keys) if cell_type == "mix_boss": if not has_boss: has_boss = True name = random.choice(boss_keys) else: name = random.choice(elite_boss_keys) if break_time >= 1000: if cell_type == "single_boss" or "mix_boss": name = random.choice(normal_elite_keys) difficulty = mon_dic[name]["diff"] if district.count(name) >= mon_dic[name]["max"] or (symmetric and mon_dic[name]["max"]<=2): continue if district.count(name) >= 1: difficulty = round(difficulty * (alpha + (1.5*(1-alpha))/district.count(name)),1) if n-sum(diffList)<=minDiff: district.append(minName) diffList.append(minDiff+1) continue else: if difficulty > n-sum(diffList)+beta: continue else: if district.count(name) == 0: difficulty = max(difficulty*1.4, difficulty+6) district.append(name) diffList.append(difficulty) # print(diffList,",难度系数=", sum(diffList)) return district, diffList def setable(list): return [tuple(item) for item in list] def generalDistrictMapSpawn(n, alpha, beta, minDiff, minName, mon_dic, cell_type, besiege, wallNum, cubeNum): # 前几个参数和分区函数相同 # besiege表示每个怪物被墙围住的概率%(0-100) # wallNum, cubeANum, cubeBNum为三种障碍物的最大上限数量(一般wallNum=5, 15= 88: hole_type = random.randint(1,14) if hole_type == 1: coordinates = [[7,7],[7,8],[7,9],[8,7],[8,8],[8,9],[9,7],[9,8],[9,9]] obstacles=[[7,7],[7,8],[7,9],[8,7],[8,8],[8,9],[9,7],[9,8],[9,9]] wall=[[7,7],[7,8],[7,9],[8,7],[8,8],[8,9],[9,7],[9,8],[9,9]] wallNum = 0 elif hole_type == 2: 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]] 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]] 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]] wallNum = 0 elif hole_type == 3: 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]] 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]] 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]] wallNum = 0 elif hole_type == 4: 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]] 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]] 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]] wallNum = 0 elif hole_type == 5: # 四宫格 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]] 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]] 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]] wallNum = 0 elif hole_type == 6: 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]] 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]] 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]] wallNum = 0 elif hole_type == 7: # 散点地形 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)] 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)] 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)] wallNum = 0 elif hole_type == 8: # sqrt13 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)] 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)] 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)] wallNum = 0 elif hole_type == 9: # 关机图标 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)] 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)] 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)] wallNum = 0 elif hole_type == 10: # 4个C 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)] 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)] 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)] wallNum = 0 elif hole_type == 11: # Love 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)] 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)] 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)] wallNum = 0 elif hole_type == 12: # I Love QT 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)] 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)] 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)] wallNum = 0 elif hole_type == 13: # ICE 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)] 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)] 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)] wallNum = 0 else: # 短十字架 coordinates = [[7,8],[8,7],[8,8],[8,9],[9,8]] obstacles=[[7,8],[8,7],[8,8],[8,9],[9,8]] wall=[[7,8],[8,7],[8,8],[8,9],[9,8]] wallNum = 0 wall = setable(wall) coordinates = setable(coordinates) else: obstacles=[] wall=[] coordinates=[] cube=[] Monsters = randomDistrictAllocation(n, alpha, beta, minDiff, minName, mon_dic, cell_type)[0] if mon_dic == T.theme3_C_mon_dic: # 实验所特殊设置 if "RogueLabAFireArtillery" not in Monsters and cell_type in ["elite","elite_normal"]: if len(Monsters) >= 4: Monsters.append("RogueLabAFireArtillery") elif mon_dic == T.theme_destiny_mon_dic: # 实验所特殊设置 if len(Monsters) >= 4 and random.randint(1,100) >= 20: Monsters.append("RogueDestinyATimeStabilizer") if random.randint(1,100) >= 80: Monsters.append("RogueDestinyATimeStabilizer") if R.print_mode: print(Monsters) district=[] for i in range(len(Monsters)): x = random.randint(3, 13) y = random.randint(3, 13) if coordinates.count((x,y)) == 0: coordinates.append((x,y)) monsters.append([x,y]) district.append({"name": Monsters[i],"y": y,"x": x}) else: a=x b=y while coordinates.count((a,b)) != 0: a = random.randint(3, 13) b = random.randint(3, 13) if coordinates.count((a,b)) == 0: coordinates.append((a,b)) monsters.append([x,y]) district.append({"name": Monsters[i],"y": b,"x": a}) break for i in range(len(monsters)): isStop = random.randint(0, 100) x = monsters[i][0] y = monsters[i][1] if isStop >=100-besiege: if coordinates.count((x+1,y)) == 0: if obstacles.count([x+1,y]) == 0: obstacles.append([x+1,y]) cube.append((x+1, y)) coordinates.append((x+1,y)) if coordinates.count((x-1,y)) == 0: if obstacles.count([x-1,y]) == 0: obstacles.append([x-1,y]) cube.append((x-1, y)) coordinates.append((x-1,y)) if coordinates.count((x,y+1)) == 0: if obstacles.count([x,y+1]) == 0: obstacles.append([x,y+1]) cube.append((x, y+1)) coordinates.append((x,y+1)) if coordinates.count((x,y-1)) == 0: if obstacles.count([x,y-1]) == 0: obstacles.append([x,y-1]) cube.append((x, y-1)) coordinates.append((x,y-1)) while len(wall) 0: # print("有重复!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!:", set(wall).intersection(set(cube))) # import sys # sys.exit() # 中断代码执行 return wall, cube, district # 子房到实际坐标xy映射 def sub_cell_map(point_list, cell): if type(point_list) == list: result = [] for point in point_list: result.append((point[0]+15*cell[0], point[1]+15*cell[1])) else: result = (point_list[0]+15*cell[0], point_list[1]+15*cell[1]) return result # 实际坐标xy到子房映射 def sub_cell_map_reverse(xy): return (int((xy[0]-2)/15), int((xy[1]-2)/15)) def dynamic_cube_num(diff): return int(min(max(20, 0.6*diff), 45)) def random_cell_generate(diff, monster_dic, cell_type, cell): diff = int(diff * min(1.6, max(0.7, random.normalvariate(1,1)))) wall, cube, district = generalDistrictMapSpawn(diff, 0.7, 8, 5, list(monster_dic.keys())[0], monster_dic, cell_type, 80, 5, dynamic_cube_num(diff)) for mon in district: new_xy = sub_cell_map((mon["x"], mon["y"]), cell) mon["x"] = new_xy[0] mon["y"] = new_xy[1] final_wall = sub_cell_map(wall, cell) final_cube = sub_cell_map(cube, cell) return final_wall, final_cube, district def generate_xy_symmetric_points(points): new_points = set() # 使用集合来自动去除重复的点 max_coordinate = 16 # 假设最大坐标为16 for x, y in points: # 计算x轴和y轴的对称点 symmetric_point_x = (max_coordinate - x, y) symmetric_point_y = (x, max_coordinate - y) # 添加原始点和对称点到新集合中,集合自动处理重复值 new_points.add((x, y)) new_points.add(symmetric_point_x) new_points.add(symmetric_point_y) # 计算所有点的双轴对称点 for x, y in list(new_points): symmetric_point_xy = (max_coordinate - x, max_coordinate - y) new_points.add(symmetric_point_xy) return list(new_points) # 将集合转换回列表 # xy对称性区域 def xy_SymmetricDistrictMapSpawn(n, alpha, beta, minDiff, minName, mon_dic, cell_type, besiege, wallNum, cubeNum, level_num): # 前几个参数和分区函数相同 # besiege表示每个怪物被墙围住的概率%(0-100) # wallNum, cubeANum, cubeBNum为三种障碍物的最大上限数量(一般wallNum=5, 15=30: if random.randint(1,100)>=50: sym_type = "axis" else: sym_type = "centre" if sym_type == "corner": if R.difficulty == "Easy" and cell_type == "elite": cell_type = "normal_elite" if R.difficulty == "Easy" and (level_num - 1) % 5 + 1 <= 2: cell_type = "normal" Monsters = [] smallMonsters = randomDistrictAllocation(n, alpha, beta, minDiff, minName, mon_dic, cell_type, symmetric=True)[0] smallMonsters = smallMonsters[1:max(2,min(3,len(smallMonsters)+1))] elif sym_type == "axis": Monsters = [random.choice(randomDistrictAllocation(n, alpha, beta, minDiff, minName, mon_dic, cell_type="elite", symmetric=True)[0])] if (level_num - 1) % 5 + 1 <= l_bound: smallMonsters = randomDistrictAllocation(n, alpha, beta, minDiff, minName, mon_dic, cell_type="normal", symmetric=True)[0] else: if R.difficulty == "Easy" and cell_type == "elite": cell_type = "normal_elite" if R.difficulty == "Easy" and (level_num - 1) % 5 + 1 <= 2: cell_type = "normal" smallMonsters = randomDistrictAllocation(n, alpha, beta, minDiff, minName, mon_dic, cell_type, symmetric=True)[0] if cell_type == "normal": smallMonsters = smallMonsters[1:max(2,min(3,len(smallMonsters)+1))] else: smallMonsters = [smallMonsters[0]] (x,y) = random.choice([(5,8),(6,8),(7,8),(7,8),(8,7),(8,7),(8,6),(8,5)]) sym_points = generate_xy_symmetric_points([(x,y)]) for point in sym_points: coordinates.append((point[0],point[1])) monsters.append([point[0],point[1]]) district.append({"name": Monsters[0],"y": point[1],"x": point[0]}) if coordinates.count((point[0]+1,point[1])) == 0: if obstacles.count([point[0]+1,point[1]]) == 0: obstacles.append([point[0]+1,point[1]]) cube.append((point[0]+1,point[1])) coordinates.append((point[0]+1,point[1])) if coordinates.count((point[0]-1,point[1])) == 0: if obstacles.count([point[0]-1,point[1]]) == 0: obstacles.append([point[0]-1,point[1]]) cube.append((point[0]-1,point[1])) coordinates.append((point[0]-1,point[1])) if coordinates.count((point[0],point[1]+1)) == 0: if obstacles.count([point[0],point[1]+1]) == 0: obstacles.append([point[0],point[1]+1]) cube.append((point[0],point[1]+1)) coordinates.append((point[0],point[1]+1)) if coordinates.count((point[0],point[1]-1)) == 0: if obstacles.count([point[0],point[1]-1]) == 0: obstacles.append([point[0],point[1]-1]) cube.append((point[0],point[1]-1)) coordinates.append((point[0],point[1]-1)) else: Monsters = [random.choice(randomDistrictAllocation(n, alpha, beta, minDiff, minName, mon_dic, cell_type="elite", symmetric=True)[0])] if mon_dic == T.theme3_C_mon_dic: # 实验所特殊设置 if "RogueLabAFireArtillery" not in Monsters and cell_type in ["elite","elite_normal"]: Monsters = ["RogueLabAFireArtillery"] if (level_num - 1) % 5 + 1 <= l_bound: smallMonsters = randomDistrictAllocation(n, alpha, beta, minDiff, minName, mon_dic, cell_type="normal", symmetric=True)[0] else: if R.difficulty == "Easy" and cell_type == "elite": cell_type = "normal_elite" if R.difficulty == "Easy" and (level_num - 1) % 5 + 1 <= 2: cell_type = "normal" smallMonsters = randomDistrictAllocation(n, alpha, beta, minDiff, minName, mon_dic, cell_type, symmetric=True)[0] if cell_type == "normal": smallMonsters = smallMonsters[0:max(2,min(3,len(smallMonsters)+1))-1] if R.difficulty == "Easy" and len(smallMonsters) > 0: smallMonsters = [smallMonsters[0]] else: smallMonsters = [smallMonsters[0]] coordinates.append((8,8)) monsters.append([8,8]) district.append({"name": Monsters[0],"y": 8,"x": 8}) # print(sym_type, Monsters, smallMonsters) # print(cell_type, (level_num - 1) % 5 + 1, l_bound) for i in range(len(smallMonsters)): x = random.choice([5,6,6,7,7,7]) y = random.choice([5,6,6,7,7,7]) if coordinates.count((x,y)) == 0: coordinates.append((x,y)) monsters.append([x,y]) small_monsters.append([x,y]) district.append({"name": smallMonsters[i],"y": y,"x": x}) else: a=x b=y t = 0 while coordinates.count((a,b)) != 0: t += 1 if t >= 10000: break a = random.choice([5,6,6,7,7,7]) b = random.choice([5,6,6,7,7,7]) if coordinates.count((a,b)) == 0: coordinates.append((a,b)) monsters.append([a,b]) small_monsters.append([a,b]) district.append({"name": smallMonsters[i],"y": b,"x": a}) break for i in range(len(monsters)): isStop = random.randint(0, 100) x = monsters[i][0] y = monsters[i][1] if isStop >= 0: if coordinates.count((x+1,y)) == 0: if obstacles.count([x+1,y]) == 0: obstacles.append([x+1,y]) cube.append((x+1, y)) coordinates.append((x+1,y)) if coordinates.count((x-1,y)) == 0: if obstacles.count([x-1,y]) == 0: obstacles.append([x-1,y]) cube.append((x-1, y)) coordinates.append((x-1,y)) if coordinates.count((x,y+1)) == 0: if obstacles.count([x,y+1]) == 0: obstacles.append([x,y+1]) cube.append((x, y+1)) coordinates.append((x,y+1)) if coordinates.count((x,y-1)) == 0: if obstacles.count([x,y-1]) == 0: obstacles.append([x,y-1]) cube.append((x, y-1)) coordinates.append((x,y-1)) while len(wall)=50: sym_type = "centre" if sym_type == "corner": if R.difficulty == "Easy" and cell_type == "elite": cell_type = "normal_elite" if R.difficulty == "Easy" and (level_num - 1) % 5 + 1 <= 2: cell_type = "normal" Monsters = [] 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])] else: Monsters = [random.choice(randomDistrictAllocation(n, alpha, beta, minDiff, minName, mon_dic, cell_type="elite", symmetric=True)[0])] if (level_num - 1) % 5 + 1 <= l_bound: 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])] else: if R.difficulty == "Easy" and cell_type == "elite": cell_type = "normal_elite" if R.difficulty == "Easy" and (level_num - 1) % 5 + 1 <= 2: cell_type = "normal" 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])] coordinates.append((8,8)) monsters.append([8,8]) district.append({"name": Monsters[0],"y": 8,"x": 8}) if R.print_mode: print(sym_type, Monsters, smallMonsters) print(cell_type, (level_num - 1) % 5 + 1, l_bound) for i in range(len(smallMonsters)): x = random.choice([5,6,6,7,7,7]) y = random.choice([5,6,6,7,7,7]) if coordinates.count((x,y)) == 0: coordinates.append((x,y)) monsters.append([x,y]) small_monsters.append([x,y]) district.append({"name": smallMonsters[i],"y": y,"x": x}) else: a=x b=y t = 0 while coordinates.count((a,b)) != 0: t += 1 if t >= 10000: break a = random.choice([5,6,6,7,7,7]) b = random.choice([5,6,6,7,7,7]) if coordinates.count((a,b)) == 0: coordinates.append((a,b)) monsters.append([a,b]) small_monsters.append([a,b]) district.append({"name": smallMonsters[i],"y": b,"x": a}) break for i in range(len(monsters)): isStop = random.randint(0, 100) x = monsters[i][0] y = monsters[i][1] if isStop >= 0: if coordinates.count((x+1,y)) == 0: if obstacles.count([x+1,y]) == 0: obstacles.append([x+1,y]) cube.append((x+1, y)) coordinates.append((x+1,y)) if coordinates.count((x-1,y)) == 0: if obstacles.count([x-1,y]) == 0: obstacles.append([x-1,y]) cube.append((x-1, y)) coordinates.append((x-1,y)) if coordinates.count((x,y+1)) == 0: if obstacles.count([x,y+1]) == 0: obstacles.append([x,y+1]) cube.append((x, y+1)) coordinates.append((x,y+1)) if coordinates.count((x,y-1)) == 0: if obstacles.count([x,y-1]) == 0: obstacles.append([x,y-1]) cube.append((x, y-1)) coordinates.append((x,y-1)) while len(wall)= 95: hole_type = random.randint(1,5) if hole_type == 1: coordinates = [[7,7],[7,8],[7,9],[8,7],[8,8],[8,9],[9,7],[9,8],[9,9]] obstacles=[[7,7],[7,8],[7,9],[8,7],[8,8],[8,9],[9,7],[9,8],[9,9]] wall=[[7,7],[7,8],[7,9],[8,7],[8,8],[8,9],[9,7],[9,8],[9,9]] wallNum = 0 elif hole_type == 2: 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]] 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]] 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]] wallNum = 0 elif hole_type == 3: 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]] 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]] 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]] wallNum = 0 elif hole_type == 4: 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]] 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]] 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]] wallNum = 0 else: coordinates = [[7,8],[8,7],[8,8],[8,9],[9,8]] obstacles=[[7,8],[8,7],[8,8],[8,9],[9,8]] wall=[[7,8],[8,7],[8,8],[8,9],[9,8]] wallNum = 0 coordinates = setable(coordinates) else: obstacles=[] wall=[] coordinates=[] cube=[] Monsters = randomDistrictAllocation(n, alpha, beta, minDiff, minName, mon_dic, cell_type)[0] boss_num = 0 for m in Monsters: if m in T.boss_list: boss_num += 1 if boss_num >= 3: Monsters.remove(m) if R.print_mode: print(Monsters) district=[] for i in range(len(Monsters)): x = random.randint(3, 13) y = random.randint(3, 13) if coordinates.count((x,y)) == 0: coordinates.append((x,y)) monsters.append([x,y]) district.append({"name": Monsters[i],"y": y,"x": x}) else: a=x b=y while coordinates.count((a,b)) != 0: a = random.randint(3, 13) b = random.randint(3, 13) if coordinates.count((a,b)) == 0: coordinates.append((a,b)) monsters.append([x,y]) district.append({"name": Monsters[i],"y": b,"x": a}) break for i in range(len(monsters)): isStop = random.randint(0, 100) x = monsters[i][0] y = monsters[i][1] if isStop >=100-besiege: if coordinates.count((x+1,y)) == 0: if obstacles.count((x+1,y)) == 0: obstacles.append([x+1,y]) cube.append((x+1, y)) coordinates.append((x+1,y)) if coordinates.count((x-1,y)) == 0: if obstacles.count([x-1,y]) == 0: obstacles.append([x-1,y]) cube.append((x-1, y)) coordinates.append((x-1,y)) if coordinates.count((x,y+1)) == 0: if obstacles.count([x,y+1]) == 0: obstacles.append([x,y+1]) cube.append((x, y+1)) coordinates.append((x,y+1)) if coordinates.count((x,y-1)) == 0: if obstacles.count([x,y-1]) == 0: obstacles.append([x,y-1]) cube.append((x, y-1)) coordinates.append((x,y-1)) while len(wall)=90: shop_level = 4 sell_num = random.randint(3,4) if shop_level<=3: if random.randint(1,100)>=95: shop_level = 5 sell_num = 4 for i in range(sell_num): if shop_level==1: s = random.choice(seller_1) elif shop_level==2: s = random.choice(seller_2) elif shop_level==3: s = random.choice(seller_3) elif shop_level==4: s = random.choice(seller_4) else: s = random.choice(seller_5) if i == 0 and not R.has_ocean_shop: if R.pass_status[R.difficulty] >= 1 and level_num >= 8 and not R.story_ocean: R.has_ocean_shop = True s = "RougeStoryOcean" if R.print_mode: print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!") print("yes!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", level_num) # Test # s = "RougeShopReverseImmune" xy = sell_coordinate[i] district.append({"name": s, "y": xy[1], "x": xy[0]}) for mon in district: new_xy = sub_cell_map((mon["x"], mon["y"]), cell) mon["x"] = new_xy[0] mon["y"] = new_xy[1] final_wall = sub_cell_map(wall, cell) return final_wall, district # 祈运区 def treasure_cell_generate(cell, shop_level=1): 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)] 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)] 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)] wall = random.choice([wall1, wall2, wall3]) 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)] district = [{"name": "RougeTreasureController","y": 8,"x": 8}] for mon in district: new_xy = sub_cell_map((mon["x"], mon["y"]), cell) mon["x"] = new_xy[0] mon["y"] = new_xy[1] final_wall = sub_cell_map(wall, cell) final_cube = sub_cell_map(cube, cell) return final_wall, final_cube, district # 擂台区 def combat_decision(cell, level_num): 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)] 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)] district = [{"name": "RougeCombatAccept","y": 5,"x": 11},{"name": "RougeCombatRun","y": 11,"x": 5}] # print(R.pass_status[R.difficulty], level_num, R.story_eden, R.story_destiny) if R.pass_status[R.difficulty] >= 1 and level_num == 10 and not R.story_eden and not R.story_destiny: # print("comem on!") R.story_eden = True district = [{"name": "RougeStoryEden","y": 5,"x": 11},{"name": "RougeStoryRun","y": 11,"x": 5}] # 坐标映射 for mon in district: new_xy = sub_cell_map((mon["x"], mon["y"]), cell) mon["x"] = new_xy[0] mon["y"] = new_xy[1] final_wall = sub_cell_map(wall, cell) final_cube = sub_cell_map(cube, cell) return final_wall, final_cube, district # 赌场 def casino(cell): 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)] cube = [(8, 7), (7, 8), (9, 8), (8, 9)] district = [{"name": "RougeCasinoGamble20P","y": 5,"x": 11},{"name": "RougeCasinoRun","y": 8,"x": 8}] # 坐标映射 for mon in district: new_xy = sub_cell_map((mon["x"], mon["y"]), cell) mon["x"] = new_xy[0] mon["y"] = new_xy[1] final_wall = sub_cell_map(wall, cell) final_cube = sub_cell_map(cube, cell) return final_wall, final_cube, district