From 0cd6008673c53e5e6393cc224923cbd276243933 Mon Sep 17 00:00:00 2001 From: Soar Qin Date: Sat, 31 Oct 2026 13:58:14 +0800 Subject: [PATCH] fix(uxassist): keep quick miners within the selected vein group Restrict layout coverage and miner vein lists to the selected group so nearby deposits of the same resource cannot attract placement. Preserve neighboring vein collision checks and enforce the three-node minimum after planned burials. Tag debug snapshots with target-group semantics, validate group membership during replay, and synchronize the English and Chinese documentation. --- UXAssist/CHANGELOG.md | 4 ++-- UXAssist/Functions/Factory/MinerPlacementDebug.cs | 2 +- UXAssist/Functions/Factory/QuickMinerBuild.cs | 14 ++++++++------ UXAssist/README.md | 4 ++-- tools/tests/QuickMinerPlacementTests.cs | 9 +++++++++ 5 files changed, 22 insertions(+), 11 deletions(-) diff --git a/UXAssist/CHANGELOG.md b/UXAssist/CHANGELOG.md index 3105f0a..bd79558 100644 --- a/UXAssist/CHANGELOG.md +++ b/UXAssist/CHANGELOG.md @@ -5,7 +5,7 @@ * 1.6.3 - Unreleased * `Sunlight at night`: Base lighting on the camera and the viewed surface instead of Icarus's facing direction, including planet view. Keep building, terrain, solar-panel, and belt lighting directions synchronized, recover when the active light or planet changes, and restore native lighting when sailing, disabling the feature, or using white rendering mode. - * `Quick build Mining Machines`: Add a Factory-tab button that searches dense layouts at the nearest solid vein group using native collision shapes, including interleaving feet, joint placement of nearby miners, and a final pass to fill remaining compatible positions. `Allow restoring/burying veins` is off by default: uses only visible nodes and skips all restoration and burial calculations. When enabled, restores available buried nodes and may bury unused nodes to improve coverage. Optimizes summed vein coverage, requires at least 3 covered nodes per miner after any burial, and places the full ordinary miner layout regardless of stock, leaving ghosts awaiting missing materials. Accelerates layout searches with up to 4 background workers, capped at half the available logical processors. Writes replayable JSON snapshots during feature tuning and keeps the completion tip visible for about 8 seconds. + * `Quick build Mining Machines`: Add a Factory-tab button that searches dense layouts at the nearest solid vein group using native collision shapes, including interleaving feet, joint placement of nearby miners, and a final pass to fill remaining compatible positions. Mines only the selected group, even when another group of the same resource is nearby. `Allow restoring/burying veins` is off by default: uses only visible nodes and skips all restoration and burial calculations. When enabled, restores available buried nodes and may bury unused nodes to improve coverage. Optimizes summed vein coverage, requires at least 3 covered nodes in the selected group per miner after any burial, and places the full ordinary miner layout regardless of stock, leaving ghosts awaiting missing materials. Accelerates layout searches with up to 4 background workers, capped at half the available logical processors. Writes replayable JSON snapshots during feature tuning and keeps the completion tip visible for about 8 seconds. * `Blueprint descriptions`: Add an `Auto-fill description` button and a `Proliferation` checkbox above the description boxes in the blueprint browser, copy, and paste panels. The button replaces the main description with the blueprint's full-load material flows per minute on separate `Missing`, `Excess`, `Input`, `Output`, and `Research` lines, and writes factory and logistics power demand to a `Power` custom field. Inputs are limited to what downstream buildings can use, matrices made in a blueprint with a research-mode lab are listed under `Research`, and research-mode labs are budgeted at full working power. The checkbox defaults to on when the blueprint contains a Spray Coater. Unknown values are marked instead of shown as zero, other custom fields are preserved, and nothing is saved automatically. * 1.6.2 * `Increase maximum power usage in Logistic Stations and Advanced Mining Machines`: Fix zero or corrupted mining speeds when adjusting an Advanced Mining Machine's speed slider with the option enabled. @@ -440,7 +440,7 @@ * 1.6.3 - Unreleased * `夜间日光灯`:按镜头和当前观察位置的地表方向计算光照,不再跟随机甲朝向,行星视图也适用。统一建筑、地表、太阳能板和传送带的光照方向,在光源或行星切换后恢复功能,并在航行、关闭功能或白模渲染时恢复原版光照。 - * `快速铺设采矿机`:在「工厂」页增加按钮,按游戏实际碰撞体在最近的固体矿脉搜索密集布局,支持脚部交错、邻近矿机联动调整及结束前补入剩余可用位置。「允许恢复/掩埋矿物」默认关闭:仅使用可见矿点,跳过所有恢复和掩埋计算;开启后,恢复可恢复的掩埋矿点,并允许掩埋未被使用的矿点来提高覆盖数。以各台矿机覆盖矿点数之和为目标,要求每台在掩埋后仍覆盖至少 3 个矿点,不受库存限制地生成完整布局,缺少采矿机的位置保留待建造虚影。使用最多 4 个后台线程加速布局搜索,线程数不超过可用逻辑线程数的一半。功能调试期间输出可离线重放的 JSON 数据,完成提示保留约 8 秒。 + * `快速铺设采矿机`:在「工厂」页增加按钮,按游戏实际碰撞体在最近的固体矿脉搜索密集布局,支持脚部交错、邻近矿机联动调整及结束前补入剩余可用位置。仅开采选中的矿脉,不混入附近同种资源的其他矿脉。「允许恢复/掩埋矿物」默认关闭:仅使用可见矿点,跳过所有恢复和掩埋计算;开启后,恢复可恢复的掩埋矿点,并允许掩埋未被使用的矿点来提高覆盖数。以各台矿机覆盖矿点数之和为目标,要求每台在掩埋后仍覆盖选中矿脉的至少 3 个矿点,不受库存限制地生成完整布局,缺少采矿机的位置保留待建造虚影。使用最多 4 个后台线程加速布局搜索,线程数不超过可用逻辑线程数的一半。功能调试期间输出可离线重放的 JSON 数据,完成提示保留约 8 秒。 * `蓝图说明`:在蓝图浏览、复制和粘贴界面的说明框上方增加「自动填写说明」按钮和「增产」复选框。点击按钮会用蓝图满负荷运行时每分钟的物料流量替换原说明,按需分行列出「缺少」「多余」「输入」「输出」「研究」,并将工厂与物流耗电写入「耗电」自定义字段。输入量以下游建筑实际能消耗的量为限;蓝图含研究模式研究站时,蓝图内产出的矩阵列入「研究」行,研究模式研究站均按满负荷计入耗电。蓝图含喷涂机时,复选框默认勾选。无法计算的数值会单独标注而不显示为零,其他自定义字段保持不变,也不会自动保存蓝图。 * 1.6.2 * `提升物流塔和大型采矿机的最大功耗`:修复启用后调整大型采矿机开采速度时出现 0% 或异常速度的问题。 diff --git a/UXAssist/Functions/Factory/MinerPlacementDebug.cs b/UXAssist/Functions/Factory/MinerPlacementDebug.cs index aac7990..2a7fc04 100644 --- a/UXAssist/Functions/Factory/MinerPlacementDebug.cs +++ b/UXAssist/Functions/Factory/MinerPlacementDebug.cs @@ -15,7 +15,7 @@ internal static class MinerPlacementDebug internal sealed class Snapshot { public int schema = 4; - public string algorithm = "parallel-repack-v5-pose-exploration-min3-unlimited-stock"; + public string algorithm = "parallel-repack-v5-pose-exploration-min3-unlimited-stock-target-group"; public int minimumCoverage = MinerPlacementSolver.MinimumCoverage; public string version, gameVersion, startedUtc, outcome, error; public int planetId, veinType, veinGroup, initialStock, placedCount, totalCoverage, buriedCount; diff --git a/UXAssist/Functions/Factory/QuickMinerBuild.cs b/UXAssist/Functions/Factory/QuickMinerBuild.cs index db26784..1f08fe7 100644 --- a/UXAssist/Functions/Factory/QuickMinerBuild.cs +++ b/UXAssist/Functions/Factory/QuickMinerBuild.cs @@ -200,6 +200,7 @@ public static class QuickMinerBuild private float _probeX = float.NaN, _probeZ = float.NaN; private bool _probeRestricted; private EVeinType _type; + private int _group; private float _minX, _maxX, _minZ, _maxZ; public bool IsCurrent => GameMain.isRunning && GameMain.mainPlayer == _player && @@ -386,6 +387,7 @@ public static class QuickMinerBuild _type = vein.type; } if (group == 0) return false; + _group = group; _debug.veinGroup = group; var count = 0; for (var i = 1; i < _factory.veinCursor; i++) @@ -608,7 +610,7 @@ public static class QuickMinerBuild var node = _nodes[i]; if (!MinerComponent.IsTargetVeinInRange(node.Position, pose, _item.prefabDesc)) continue; if (node.Type != _type) { _debug.rejections.mixedType++; return; } - _covered.Add(i); + if (node.Target) _covered.Add(i); } if (_covered.Count < MinerPlacementSolver.MinimumCoverage) { _debug.rejections.noCoverage++; return; } for (var i = 0; i < _buildBoxes.Length; i++) @@ -806,7 +808,7 @@ public static class QuickMinerBuild foreach (var node in _nodes) { ref var vein = ref _factory.veinPool[node.Id]; - if (vein.id == node.Id && vein.amount > 0 && vein.type == _type && vein.pos.magnitude >= _planet.realRadius - 40f && + if (node.Target && vein.id == node.Id && vein.amount > 0 && vein.type == _type && vein.pos.magnitude >= _planet.realRadius - 40f && MinerComponent.IsTargetVeinInRange(vein.pos, pose, _item.prefabDesc)) ids.Add(node.Id); } ref var prebuild = ref _factory.prebuildPool[entry.Prebuild]; @@ -887,10 +889,10 @@ public static class QuickMinerBuild debug.coverObjectId = preview.coverObjId; debug.nativeVeins = preview.parameters?.Take(preview.paramCount).ToArray() ?? []; if (!valid || preview.condition != EBuildCondition.Ok || preview.coverObjId != 0) return false; - // Include every planned burial now, so a later miner cannot reduce this one - // below the minimum after its item has already been consumed. - debug.plannedVeins = _allowVeinReform - ? debug.nativeVeins.Where(id => !plannedBurial.Contains(id)).ToArray() : debug.nativeVeins; + // Native selection includes nearby groups of the same type. Keep only this + // group and exclude all planned burials before enforcing the minimum. + debug.plannedVeins = debug.nativeVeins.Where(id => _factory.veinPool[id].groupIndex == _group && + (!_allowVeinReform || !plannedBurial.Contains(id))).ToArray(); if (debug.plannedVeins.Length < MinerPlacementSolver.MinimumCoverage) { debug.outcome = "below-minimum-coverage"; return false; } for (var i = 0; i < preview.paramCount; i++) diff --git a/UXAssist/README.md b/UXAssist/README.md index 0191abb..a9ae846 100644 --- a/UXAssist/README.md +++ b/UXAssist/README.md @@ -85,7 +85,7 @@ * Quick build Orbital Collectors * Set a maximum number to build per operation; 0 builds as many as possible * Quick build Mining Machines - * Use the button on the Factory tab near Quick build Orbital Collectors. Places the full ordinary Mining Machine layout at the nearest solid vein group regardless of carried stock. Uses available miners from the inventory and hand; missing miners remain as ghosts awaiting materials. Every placed miner must retain at least 3 covered nodes after all planned burials; miners below that minimum are invalid. + * Use the button on the Factory tab near Quick build Orbital Collectors. Places the full ordinary Mining Machine layout at the nearest solid vein group regardless of carried stock. Mines only the selected group, even when another group of the same resource is nearby. Uses available miners from the inventory and hand; missing miners remain as ghosts awaiting materials. Every placed miner must retain at least 3 covered nodes in the selected group after all planned burials; miners below that minimum are invalid. * `Allow restoring/burying veins` is off by default. When disabled, uses only visible nodes and skips all restoration and burial calculations. Enable it to restore buried nodes unless obstructed by buildings or near Dark Fog Planetary Bases. Changes apply to the next calculation. Searches individual native collision shapes so the miner's feet can interleave where the game permits. * Uses multiple packing orders, exploration keyed by placement pose as well as candidate index, local position/rotation refinement, body-width neighbor candidates, and coordinated repacking of up to three nearby miners to seek a high sum of vein counts across all placed miners. A final pass fills remaining compatible candidates when they increase total coverage while preserving the three-node minimum. Shared nodes count once per miner; this bounded search does not guarantee a global optimum. * Reuses collision checks and runs independent layout searches on up to 4 background workers, capped at half the available logical processors. Systems with one logical processor keep the search on the main thread with a frame budget. Native terrain checks and placement stay on the main thread; worker scheduling preserves the same layout as sequential search. @@ -288,7 +288,7 @@ * 快速建造轨道采集器 * 可设置单次建造数量上限;设为 0 时尽可能多地建造 * 快速铺设采矿机 - * 点击「工厂」页中轨道采集器按钮附近的按钮,在最近的固体矿脉生成完整的普通采矿机布局,数量不受库存限制。有采矿机时正常消耗背包和手持物品,不足的位置保留待建造虚影,等待补充材料。所有计划掩埋完成后,每台矿机仍须覆盖至少 3 个矿点;少于 3 个的视为无效,不予铺设。 + * 点击「工厂」页中轨道采集器按钮附近的按钮,在最近的固体矿脉生成完整的普通采矿机布局,数量不受库存限制。仅开采选中的矿脉,即使附近有同种资源的其他矿脉也不会混入。有采矿机时正常消耗背包和手持物品,不足的位置保留待建造虚影,等待补充材料。所有计划掩埋完成后,每台矿机仍须覆盖选中矿脉的至少 3 个矿点;少于 3 个的视为无效,不予铺设。 * 「允许恢复/掩埋矿物」默认关闭。关闭时仅使用可见矿点,跳过所有恢复和掩埋计算;开启后,先恢复未被建筑阻挡且不在黑雾行星基地附近的掩埋矿点。选项变更从下次计算生效。按原版独立碰撞体搜索布局,保留游戏允许的矿机脚部交叉空间。 * 比较多种铺设顺序,同时按候选序号及位置朝向探索不同布局,细调位置和朝向,按机身宽度补充紧邻候选,并允许邻近的两三台矿机一起重新布局,尽量提高各台矿机覆盖矿点数之和。结束前再扫描全部候选,继续补入能提高总覆盖数、且不破坏每台至少覆盖 3 点要求的矿机。同一矿点被多台矿机覆盖时重复计数。计算有界,不保证全局最优。 * 复用碰撞检查结果,使用最多 4 个后台线程并行搜索独立布局,线程数不超过可用逻辑线程数的一半。单逻辑线程系统继续在主线程按每帧预算计算。原生地形检查和实际铺设保留在主线程;并行调度与顺序搜索生成相同布局。 diff --git a/tools/tests/QuickMinerPlacementTests.cs b/tools/tests/QuickMinerPlacementTests.cs index 53bec1a..92498a7 100644 --- a/tools/tests/QuickMinerPlacementTests.cs +++ b/tools/tests/QuickMinerPlacementTests.cs @@ -381,6 +381,15 @@ internal static class QuickMinerPlacementTests Check(snapshot.schema is 1 or 2 or 3 or 4, "Unsupported debug snapshot schema."); Check(snapshot.nodes != null && snapshot.candidates != null && snapshot.buildColliders != null && snapshot.minerColliders != null && snapshot.phases != null, "This snapshot contains summary data only and cannot be replayed. Run quick miner placement again with the updated build."); + if (snapshot.algorithm?.EndsWith("-target-group", StringComparison.Ordinal) == true) + { + var targetIds = snapshot.nodes.Where(node => node.target).Select(node => node.id).ToHashSet(); + Check(snapshot.candidates.All(candidate => candidate.covered.All(index => snapshot.nodes[index].target)), + "Candidate coverage must exclude neighboring vein groups, including those of the same type."); + Check((snapshot.placements ?? []).All(placement => + (placement.plannedVeins ?? []).Concat(placement.finalVeins ?? []).All(targetIds.Contains)), + "Planned and final miner parameters must contain only nodes from the selected vein group."); + } Console.WriteLine($"Snapshot: outcome={snapshot.outcome}, nodes={snapshot.nodes.Length}, candidates={snapshot.candidates.Length}, placed={snapshot.placedCount}, actual coverage={snapshot.totalCoverage}"); foreach (var failure in (snapshot.placements ?? []).Where(p => p.outcome != "placed").GroupBy(p => (p.outcome, p.nativeCondition))) Console.WriteLine($"Placement {failure.Key.outcome}: native={failure.Key.nativeCondition}, count={failure.Count()}");