Skip to content

feat(recipe): 为配方查找增加基于方块约束的搜索树剪枝 - #108

Open
Gu-ZT wants to merge 4 commits into
Anvil-Dev:dev/1.21.1from
Gu-ZT:recipe/1.21.1
Open

feat(recipe): 为配方查找增加基于方块约束的搜索树剪枝#108
Gu-ZT wants to merge 4 commits into
Anvil-Dev:dev/1.21.1from
Gu-ZT:recipe/1.21.1

Conversation

@Gu-ZT

@Gu-ZT Gu-ZT commented Aug 23, 2026

Copy link
Copy Markdown
Contributor
  • InWorldRecipeManager 注册配方时预提取 HasBlockBase 谓词的方块约束(offset 与非空 blocks 集合)
  • 触发查找时按相对位置批量去重读取实际方块状态,一次性失效所有不可能匹配的配方
  • 未限制对应位置方块(blocks 为空)的谓词不产生约束,所在配方永不剪枝
  • 候选集沿用既有优先级排序,完整匹配与执行循环语义不变

- InWorldRecipeManager 注册配方时预提取 HasBlockBase 谓词的方块约束(offset 与非空 blocks 集合)
- 触发查找时按相对位置批量去重读取实际方块状态,一次性失效所有不可能匹配的配方
- 未限制对应位置方块(blocks 为空)的谓词不产生约束,所在配方永不剪枝
- 候选集沿用既有优先级排序,完整匹配与执行循环语义不变
@Gugle2308

Copy link
Copy Markdown

⏳ Retrying in 2.3s (attempt 1/3)...

@Gugle2308

Copy link
Copy Markdown

⏳ Retrying in 5.4s (attempt 2/3)...

@Gugle2308

Copy link
Copy Markdown

❌ API failed after 3 retries — HTTP 503: Service temporarily unavailable

@Gugle2308

Copy link
Copy Markdown

API call failed after 3 retries: HTTP 503: Service temporarily unavailable

@Gugle2308

Copy link
Copy Markdown

🌿 Roseau API Breaking Change Report

Module Status Breaking Changes
codec ✅ Compatible 0
collision ✅ Compatible 0
config ✅ Compatible 0
integration ✅ Compatible 0
moveable-entity-block ✅ Compatible 0
network ✅ Compatible 0
rendering ⚪ Skipped
space-select ✅ Compatible 0
font ✅ Compatible 0
util ✅ Compatible 0
explosion ✅ Compatible 0
rpc ✅ Compatible 0
multiblock ✅ Compatible 0
recipe ✅ Compatible 0
registrum ✅ Compatible 0
sync ✅ Compatible 0
wheel ✅ Compatible 0
main ✅ Compatible 0

Full CSVs: see the Artifacts section of this workflow run.

Gu-ZT and others added 2 commits August 23, 2026 20:05
- 相同 offset 与方块集合的约束在注册时合并为共享判定节点,构成节点与配方槽位的二部连线
- 触发时每个节点至多判定一次实际方块状态,相同 offset 的多个节点共享同一次世界读取
- 节点判定失败沿连线一票否决全部相连配方,索引内配方全部失效时立即终止查找
- 绕过 register 直接写入 recipeHolders 的配方保守放行且不参与提前终止,行为与剪枝前一致
- BlockStatePredicate 新增 cannotMatch 方法,testWithoutEntity 复用其实现,剪枝否决条件与谓词语义收敛为一处代码
- PrunePlan 节点判定改用代表谓词的 cannotMatch,替代手写 state.is 复刻
- NodeKey 引入 BlockSetKey 规范化键:标签按 TagKey 值合并、直接集合按排序后方块 id 列表合并,无键 Holder 以实例身份兜底
- NodeKey 构造时归一化 Vec3 偏移(-0.0 归为 0.0),避免浮点表示差异导致无法合并
- resolve 以 try/finally 保证异常路径同样复位失效计数
- RECIPE_ORDER 追加配方 id 决胜,消除同优先级比较不对称带来的不确定遍历顺序
- 注释说明 slotMap 无移除路径时提前终止的失效风险
@Gugle2308

Copy link
Copy Markdown

⏳ Retrying in 2.4s (attempt 1/3)...

@Gugle2308

Copy link
Copy Markdown

⏳ Retrying in 4.5s (attempt 2/3)...

@Gugle2308

Copy link
Copy Markdown

❌ API failed after 3 retries — HTTP 503: Service temporarily unavailable

@Gugle2308

Copy link
Copy Markdown

API call failed after 3 retries: HTTP 503: Service temporarily unavailable

- PrunePlan 新增 OffsetGroup,注册时把节点按归一化 offset 分组
- resolve 改为逐组判定:每组一次 BlockCache 读取,组内节点共享
- 移除每次触发分配的 states 哈希表与重复 Vec3 哈希
- nodes 降级为注册期去重索引,否决/提前终止/兜底放行语义不变
@Gugle2308

Copy link
Copy Markdown

❌ Non-retryable error (HTTP 400): HTTP 400: Format Error

@Gugle2308

Copy link
Copy Markdown

HTTP 400: Format Error

@Gugle2308

Copy link
Copy Markdown

🌿 Roseau API Breaking Change Report

Module Status Breaking Changes
codec ✅ Compatible 0
collision ✅ Compatible 0
config ✅ Compatible 0
integration ✅ Compatible 0
moveable-entity-block ✅ Compatible 0
network ✅ Compatible 0
rendering ⚪ Skipped
space-select ✅ Compatible 0
font ✅ Compatible 0
util ✅ Compatible 0
explosion ✅ Compatible 0
rpc ✅ Compatible 0
multiblock ✅ Compatible 0
recipe ✅ Compatible 0
registrum ✅ Compatible 0
sync ✅ Compatible 0
wheel ✅ Compatible 0
main ✅ Compatible 0

Full CSVs: see the Artifacts section of this workflow run.

@Gugle2308

Copy link
Copy Markdown

🌿 Roseau API Breaking Change Report

Module Status Breaking Changes
codec ✅ Compatible 0
collision ✅ Compatible 0
config ✅ Compatible 0
integration ✅ Compatible 0
moveable-entity-block ✅ Compatible 0
network ✅ Compatible 0
rendering ⚪ Skipped
space-select ✅ Compatible 0
font ✅ Compatible 0
util ✅ Compatible 0
explosion ✅ Compatible 0
rpc ✅ Compatible 0
multiblock ✅ Compatible 0
recipe ✅ Compatible 0
registrum ✅ Compatible 0
sync ✅ Compatible 0
wheel ✅ Compatible 0
main ✅ Compatible 0

Full CSVs: see the Artifacts section of this workflow run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants