plan-lab: the climb story first, tree and rules folded away

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-09-27 13:04:57 -05:00
parent a2d5706d8e
commit 8e419f95e8
2 changed files with 88 additions and 53 deletions
+23 -4
View File
@@ -485,6 +485,7 @@
}
for (let d = 1; d <= D; d++) { dp.entry[d - 1] += dp.counts[d] * net(1); dp.spent += dp.counts[d] * price(1); dp.treasury += dp.counts[d] * price(1) * PLAN.fee; } // Rule 0, once, when the org is built
deepRender('Reset. Everyone at level 1, you included; entries paid.');
const ol = document.getElementById('deepStory'); if (ol) ol.innerHTML = '<li class="head">Start. You and everyone under you hold level 1. Your ' + cnt(dp.counts[1]) + ' directs paid their entries: <b>' + $$(dp.entry[0]) + '</b> to you after the fee. Press Run one wave.</li>';
}
// n payments of `amt` for level L from depth `from`: skip `skipN`, then the gap rule on aggregate levels
function deepPay(n, from, L, amt, skipN, rem){
@@ -528,11 +529,29 @@
}
if (note) document.getElementById('deepNote').textContent = note;
}
function storyLine(html, cls){ const ol = document.getElementById('deepStory'); if (!ol) return; if (ol.firstChild && /Nothing has happened/.test(ol.firstChild.textContent)) ol.innerHTML = ''; const li = document.createElement('li'); if (cls) li.className = cls; li.innerHTML = html; ol.prepend(li); while (ol.children.length > 40) ol.removeChild(ol.lastChild); }
function deepRun(k){
const before = dp ? dp.levels[0] : 1; let ran = 0;
for (let i = 0; i < k; i++) { if (dp && dp.levels[0] >= PLAN.maxL) break; deepWave(); ran++; }
if (!dp) deepReset();
let ran = 0;
for (let i = 0; i < k; i++) {
if (dp.levels[0] >= PLAN.maxL) break;
const lv0 = dp.levels[0], cash0 = dp.cash[0], lic0 = dp.lic[0], adm0 = dp.treasury, above0 = dp.above;
deepWave(); ran++;
const lv1 = dp.levels[0], dCash = dp.cash[0] - cash0, dLic = dp.lic[0] - lic0;
const d = lv0; // the depth whose purchase this wave could reach you
const L = d + 1;
let html = '<b>Wave ' + dp.waves + '.</b> Every position bought its next level. ';
if (d <= dp.D) html += 'The ' + cnt(dp.counts[d]) + ' positions at depth ' + d + ' bought level ' + L + ' (' + product(L) + ', ' + $$(price(L)) + ' each, ' + $$(net(L)) + ' after the fee), and level-' + L + ' money is yours. ';
if (dLic) html += 'The <span class="chip lic">first one</span> was your licence ' + lv1 + ': you were upgraded in the same block and its cost climbed on above you. ';
if (dCash > 0) html += 'The rest reached you as <span class="chip cash">cash</span>: <b>' + $$(dCash) + '</b>. ';
if (!dLic && dCash <= 0) html += 'Nothing reached you: that depth is empty at this fill, or you are at the top. ';
html += 'Everything the other depths bought paid the people between you and them, or climbed past you. Admin wallet took ' + $$(dp.treasury - adm0) + ' this wave. ';
html += '<span class="chip reach">You: level ' + lv1 + ', reach depth 1 to ' + Math.min(lv1, dp.D) + '</span>';
storyLine(html, dLic ? 'lic' : 'cash');
}
const after = dp.levels[0];
deepRender(ran + ' wave' + (ran === 1 ? '' : 's') + ' run. ' + (after > before ? 'You went from level ' + before + ' to ' + after + ' without buying anything: the first payment at each new depth was your licence.' : after >= PLAN.maxL ? 'You hold level ' + PLAN.maxL + ', the top of the ladder. Every payment from every depth is cash from here on.' : 'Your level did not move this time.'));
if (after >= PLAN.maxL) storyLine('<b>Top of the ladder.</b> You hold level ' + PLAN.maxL + '. From here every payment from every depth is cash, and there is no level 9: positions ' + PLAN.maxL + ' deep pay the people between you and them.', 'head');
deepRender(ran + ' wave' + (ran === 1 ? '' : 's') + ' run.');
}
document.getElementById('deepWave').addEventListener('click', () => deepRun(1));
document.getElementById('deepWave5').addEventListener('click', () => deepRun(5));
@@ -561,7 +580,7 @@
document.getElementById('wmOn').setAttribute('aria-pressed', String(PLAN.wm));
const yl = document.getElementById('youLevel'); yl.max = PLAN.maxL; yl.value = 1; // a new plan starts you at level 1, like everyone
document.getElementById('youLevelVal').textContent = yl.value;
document.getElementById('deepHead').textContent = 'All ' + PLAN.maxL + ' levels, simulated by depth';
{ const dh = document.getElementById('deepHead'); if (dh) dh.textContent = 'Watch one position climb all ' + PLAN.maxL + ' levels'; }
svg.setAttribute('aria-label', PLAN.w + '-wide matrix under you');
build(); deepReset();
}