From b092ec53ae0ef1104dd4ca9e21d28e8e9d5fae2e Mon Sep 17 00:00:00 2001 From: DKChan <524912269@qq.com> Date: Sun, 20 Sep 2026 01:16:54 +0800 Subject: [PATCH] =?UTF-8?q?fix(terrain-variation):=20=E5=8F=98=E5=BC=82?= =?UTF-8?q?=E5=B8=83=E7=BD=AE=E8=BF=9E=E9=80=9A=E7=89=87=E9=9A=94=E7=A6=BB?= =?UTF-8?q?=E2=80=94=E2=80=94=E6=96=B0=E7=89=87=E7=A6=81=E4=B8=8E=E5=85=B6?= =?UTF-8?q?=E4=BB=96=E5=B7=B2=E5=B8=83=E7=89=87=208=20=E9=82=BB=E8=B4=B4?= =?UTF-8?q?=E6=8E=A5=EF=BC=88R3=20=E9=9A=8F=E6=9C=BA=E6=B5=81=E4=B8=8B?= =?UTF-8?q?=E6=9A=B4=E9=9C=B2=E7=9A=84=E7=B2=98=E8=BF=9E=E5=90=88=E6=B5=81?= =?UTF-8?q?=20bug=EF=BC=8C=E5=8D=95=E7=89=87=20=E2=89=A4pack=5Fmax=20?= =?UTF-8?q?=E6=96=AD=E8=A8=80=E5=9B=9E=E5=BD=92=EF=BC=89=EF=BC=9Bregistry?= =?UTF-8?q?=20variant=5Fplace=20=E9=BB=84=E9=87=91=E5=90=91=E9=87=8F?= =?UTF-8?q?=E6=8C=89=20R3=20=E5=85=AC=E5=BC=8F=E9=87=8D=E7=99=BB=E8=AE=B0?= =?UTF-8?q?=205785725196205023206?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/battle_orchestrator.gd | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/prototypes/dungeon-sweeper-vertical-slice/core/battle_orchestrator.gd b/prototypes/dungeon-sweeper-vertical-slice/core/battle_orchestrator.gd index 1d862054..466fef49 100644 --- a/prototypes/dungeon-sweeper-vertical-slice/core/battle_orchestrator.gd +++ b/prototypes/dungeon-sweeper-vertical-slice/core/battle_orchestrator.gd @@ -193,28 +193,42 @@ func _place_variants(board: BoardData) -> void: var pack_size: int = mini(total - placed.size(), stream.randi_range(2, int(db.variation.pack_max))) var free: Array = [] for c in candidates: - if not placed.has(c): - free.append(c) + # 新片种子/生长格禁与其他已布片 8 邻贴接——否则两片粘连成一个超 pack_max 的连通分量 + # (R3 随机流下实测暴露:独立生长的相邻片合流击穿单片上限断言) + if placed.has(c) or _adjacent_to_packs(board, placed, c): + continue + free.append(c) if free.is_empty(): break var seed_c: Vector2i = free[stream.randi_range(0, free.size() - 1)] placed[seed_c] = true var pack: Array = [seed_c] + var pack_set := {seed_c: true} while pack.size() < pack_size: var fringe: Array = [] for c in pack: for n in board.neighbors8(c): - if candidates.has(n) and not placed.has(n) and not fringe.has(n): + if candidates.has(n) and not placed.has(n) and not fringe.has(n) \ + and not _adjacent_to_packs(board, placed, n, pack_set): fringe.append(n) if fringe.is_empty(): break # 生长域耗尽——该片就地收束(数量不足总目标为合法态,候选域碎片化时触发) var nxt: Vector2i = fringe[stream.randi_range(0, fringe.size() - 1)] placed[nxt] = true + pack_set[nxt] = true pack.append(nxt) for c in placed.keys(): board.variants[c] = [String(vrow.variant_id)] +# 候选格是否与其他已布片(own_pack 之外的 placed 格)8 邻贴接——片间隔离保证连通分量 = 单片 ≤ pack_max +func _adjacent_to_packs(board: BoardData, placed: Dictionary, c: Vector2i, own_pack: Dictionary = {}) -> bool: + for m in board.neighbors8(c): + if placed.has(m) and not own_pack.has(m): + return true + return false + + # ---- 事件缓冲(轮 facts 收集;结算触发 = Waiting 相位编排点,不依赖到达序)---- func _on_cell_revealed(evt: Dictionary) -> void: