Files
R8Forge/include
starcells a0790a66e2 Add a tape-length search: Dijkstra with the real block cost
Layers are not characters.  solve_cost runs Dijkstra over the same state graph
with an edge weight of what the block actually assembles to:

    w = 3 (biz + flb + rnz) + 2 * span(cell addresses) + sum(op)
        op = 1 for flb, 4 for set_1

Dial buckets, pop in cost order, the first pop of the goal is the shortest
tape.  Give it max_cost and it becomes branch and bound: anything past the
bound never enters the queue.

Exhausted regions on the full adder with adjacent cells:

    max_cost 20    1,086 states      0.0s
    max_cost 40  128,528 states      0.1s
    max_cost 50  999,448 states      0.7s
    max_cost 60  7,671,626 states   12.8s
    max_cost 65 20,153,459 states   47.6s

About 2.6x states per 5 cost, about 32 bytes per state, so max_cost 80 is
~350M states / 11GB and 82 would be ~600M / 19GB.  The block weight leaves out
the hop from the previous sacrifice (that would make the cost depend on
history and Dijkstra would stop working); the emitter adds it when it reports
the real length -- the five layer program is 82 in the model, 87 on the tape.

The first version of the bucket ring only looked one max-edge-weight ahead for
work, so it declared 'nothing under the limit' while the queue still had
states further out.  That made the small limits look sound when they were not;
advancing to the next nonempty bucket fixed it.
2026-11-06 08:49:11 +08:00
..