@modelstatus/cli 0.1.40 → 0.1.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/tui/game/dk-core.js +166 -17
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modelstatus/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.41",
|
|
4
4
|
"description": "Track which AI models you use, where, and never get surprised by a retirement. Free offline model-health for any repo (mm status), browser sign-in for cloud inventory + alerts.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"llm",
|
package/src/tui/game/dk-core.js
CHANGED
|
@@ -85,7 +85,7 @@ export function bonusForLevel(level) {
|
|
|
85
85
|
return 5000 + level * 1000;
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
const SCHEMA =
|
|
88
|
+
const SCHEMA = 3; // bumped: board contract now varies per level (N/slope/ladder placement)
|
|
89
89
|
|
|
90
90
|
// ---- Level scaling (pure, tested monotonic) --------------------------------
|
|
91
91
|
/** DK barrel-throw cadence in TICKS — faster (shorter) as you climb. */
|
|
@@ -121,16 +121,145 @@ export function boardSize(width, height) {
|
|
|
121
121
|
return { BOARD_W, BOARD_H };
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
function buildSlope(baseRow, w, down, amp) {
|
|
124
|
+
function buildSlope(baseRow, w, down, amp, slopeEvery = SLOPE_EVERY) {
|
|
125
125
|
const offs = new Array(w);
|
|
126
126
|
for (let x = 0; x < w; x++) {
|
|
127
|
-
const steps = Math.floor(x /
|
|
127
|
+
const steps = Math.floor(x / slopeEvery);
|
|
128
128
|
const off = down ? steps : -steps;
|
|
129
129
|
offs[x] = baseRow + Math.max(-amp, Math.min(amp, off));
|
|
130
130
|
}
|
|
131
131
|
return offs;
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
+
// ---- Per-level layout generator (PURE, deterministic) ----------------------
|
|
135
|
+
/* `levelLayout(level, BOARD_W, BOARD_H)` returns the few geometry knobs initGame
|
|
136
|
+
* reads instead of hardcoded values, keyed on k = (level-1) % 10 so levels 1-10
|
|
137
|
+
* are distinct and 11+ cycle (L11 === L1). It is a pure function of its three
|
|
138
|
+
* args only — no Math.random / Date.now / rngSeed — so the same (size, level)
|
|
139
|
+
* yields a byte-identical board on node and the bun binary (INVARIANT 4).
|
|
140
|
+
*
|
|
141
|
+
* Every knob is CLAMPED to the feasible window so it can never break an invariant:
|
|
142
|
+
* - N is clamped to [3, Nmax(BOARD_H)] (Nmax = largest N<=5 with gap>=GAP_MIN),
|
|
143
|
+
* so on the minimum 28x12 board every level collapses to N=3 (== today) and a
|
|
144
|
+
* small terminal never gets an unsafe extra girder. (INVARIANT 3.)
|
|
145
|
+
* - amp is only ever LOWERED below the existing floor((gap-1)/2) clamp, AND
|
|
146
|
+
* further capped so every ladder spans >=2 rows (gap-2*amp>=2 → amp<=(gap-2)/2)
|
|
147
|
+
* — so girders never cross (amp<gap/2, INVARIANT 2) and ladders are never the
|
|
148
|
+
* 1-row fragile latches the critic flagged (B3).
|
|
149
|
+
* - ladder columns are clamped to [2, BOARD_W-3] (double-wide [col,col+1] fits,
|
|
150
|
+
* INVARIANT 1) AND nudged so no two ladders' footprints overlap (>=2 apart),
|
|
151
|
+
* which the critic flagged would otherwise shadow a ladder in ladderAt (B2).
|
|
152
|
+
* - dkCol / princessCol clamped to [2, BOARD_W-3].
|
|
153
|
+
* The slope DIRECTION/cadence knobs (slopeDownFor, slopeEvery) only move points
|
|
154
|
+
* WITHIN the ±amp band, so no pattern can induce a crossing. Up-slope traversal
|
|
155
|
+
* (the critic's B1) is handled in stepPlaying's grounded branch (riser auto-mount).
|
|
156
|
+
*/
|
|
157
|
+
const GAP_MIN = 4; // min girder spacing for the N-delta to take effect on tall boards
|
|
158
|
+
const clampInt = (v, lo, hi) => (v < lo ? lo : v > hi ? hi : v);
|
|
159
|
+
// Per-k knob tables (k = (level-1) % 10). All bounded; clamps make them safe.
|
|
160
|
+
const L_NDELTA = [0, 0, 1, 0, 1, 0, 2, 1, 0, 2]; // extra girders (capped at Nmax)
|
|
161
|
+
const L_AMPCAP = [2, 1, 2, 0, 2, 1, 2, 1, 2, 0]; // some levels flatter (amp 0/1)
|
|
162
|
+
const L_SLOPEEV = [6, 5, 7, 6, 4, 6, 8, 5, 6, 4]; // stair cadence (cosmetic)
|
|
163
|
+
const L_SLOPEPAT = [0, 0, 1, 2, 3, 4, 5, 6, 7, 1]; // slope-direction pattern id
|
|
164
|
+
const L_LADSTY = [0, 1, 0, 5, 4, 0, 0, 1, 5, 0]; // ladder placement style id
|
|
165
|
+
const L_STAGMAG = [3, 2, 4, 3, 5, 2, 3, 4, 2, 3]; // ladder stagger magnitude
|
|
166
|
+
const L_DKSTY = [0, 0, 1, 0, 2, 3, 1, 0, 2, 3]; // DK column style id (cosmetic)
|
|
167
|
+
const L_PRSTY = [0, 0, 1, 2, 0, 3, 4, 0, 5, 0]; // princess column style id
|
|
168
|
+
|
|
169
|
+
/** Largest girder count N in [3,5] whose even spacing gap>=GAP_MIN; else 3. The
|
|
170
|
+
* Math.max(3,…) floor (not the gap gate) is what guarantees the small board. */
|
|
171
|
+
function nMaxForHeight(BOARD_H) {
|
|
172
|
+
let best = 3;
|
|
173
|
+
for (let n = 3; n <= 5; n++) if (Math.floor((BOARD_H - 2) / n) >= GAP_MIN) best = n;
|
|
174
|
+
return best;
|
|
175
|
+
}
|
|
176
|
+
/** Per-girder slope direction (down-rightward) for a slope pattern. ANY value is
|
|
177
|
+
* safe (clamped to ±amp around distinct baseRows → never crosses). */
|
|
178
|
+
function slopeDownFor(pat, i) {
|
|
179
|
+
switch (pat) {
|
|
180
|
+
case 1: return i % 2 === 1; // alternating from odd (phase flip)
|
|
181
|
+
case 2: return true; // all-down
|
|
182
|
+
case 3: return false; // all-up
|
|
183
|
+
case 4: return Math.floor(i / 2) % 2 === 0; // zig-zag pairs
|
|
184
|
+
case 5: return true; // all-down (gentle via slopeEvery)
|
|
185
|
+
case 6: return false; // all-up
|
|
186
|
+
case 7: return i % 2 === 0; // alternating from even
|
|
187
|
+
case 0:
|
|
188
|
+
default: return i % 2 === 0; // alternating from even (classic)
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
export function levelLayout(level, BOARD_W, BOARD_H) {
|
|
192
|
+
const k = (((level - 1) % 10) + 10) % 10;
|
|
193
|
+
const Nmax = nMaxForHeight(BOARD_H);
|
|
194
|
+
const N = clampInt(3 + L_NDELTA[k], 3, Nmax);
|
|
195
|
+
const gap = Math.floor((BOARD_H - 2) / N);
|
|
196
|
+
// amp: never above today's floor((gap-1)/2); also cap so every ladder spans
|
|
197
|
+
// >=2 rows (gap - 2*amp >= 2 ⇒ amp <= (gap-2)/2). amp<gap/2 ⇒ no girder cross.
|
|
198
|
+
let amp = Math.max(0, Math.min(L_AMPCAP[k], Math.floor((gap - 1) / 2)));
|
|
199
|
+
amp = Math.max(0, Math.min(amp, Math.floor((gap - 2) / 2)));
|
|
200
|
+
const slopeEvery = L_SLOPEEV[k];
|
|
201
|
+
const pat = L_SLOPEPAT[k];
|
|
202
|
+
const sty = L_LADSTY[k];
|
|
203
|
+
const stag = L_STAGMAG[k];
|
|
204
|
+
const lo = 2, hi = BOARD_W - 3;
|
|
205
|
+
|
|
206
|
+
// Ladder columns: one per adjacent pair, per-level placement style, then nudged
|
|
207
|
+
// so no two footprints [col,col+1] overlap (>=2 apart) and all in [lo,hi].
|
|
208
|
+
const cols = [];
|
|
209
|
+
for (let i = 0; i < N - 1; i++) {
|
|
210
|
+
const frac = (i + 1) / N;
|
|
211
|
+
let base;
|
|
212
|
+
switch (sty) {
|
|
213
|
+
case 1: base = lo + 2 + i * 2 + (i % 2 ? 0 : 1); break; // clustered-left
|
|
214
|
+
case 2: base = hi - 2 - i * 2; break; // clustered-right
|
|
215
|
+
case 3: base = Math.floor(frac * BOARD_W) + (i % 2 ? stag : -stag); break; // reversed stagger
|
|
216
|
+
case 4: base = hi - 3 - (N - 2 - i) * 2 - (i % 2 ? stag : 0); break; // clustered-right staggered
|
|
217
|
+
case 5: base = (i % 2 === 0) ? lo + 1 + i : hi - 1 - i; break; // near-edges alternating
|
|
218
|
+
case 0:
|
|
219
|
+
default: base = Math.floor(frac * BOARD_W) + (i % 2 ? -stag : stag); // spread (classic)
|
|
220
|
+
}
|
|
221
|
+
cols.push(clampInt(base, lo, hi));
|
|
222
|
+
}
|
|
223
|
+
for (let i = 1; i < cols.length; i++) {
|
|
224
|
+
for (let j = 0; j < i; j++) {
|
|
225
|
+
let guard = 0;
|
|
226
|
+
while (Math.abs(cols[i] - cols[j]) < 2 && guard++ < 256) {
|
|
227
|
+
cols[i] = cols[i] + 2 <= hi ? cols[i] + 2 : cols[i] - 2;
|
|
228
|
+
if (cols[i] < lo) { cols[i] = lo; break; }
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
cols[i] = clampInt(cols[i], lo, hi);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
let dkCol;
|
|
235
|
+
switch (L_DKSTY[k]) {
|
|
236
|
+
case 1: dkCol = BOARD_W - 3; break;
|
|
237
|
+
case 2: dkCol = BOARD_W - 4; break;
|
|
238
|
+
case 3: dkCol = 3; break;
|
|
239
|
+
case 0:
|
|
240
|
+
default: dkCol = 2;
|
|
241
|
+
}
|
|
242
|
+
const cen = Math.floor(BOARD_W / 2);
|
|
243
|
+
let princessCol;
|
|
244
|
+
switch (L_PRSTY[k]) {
|
|
245
|
+
case 1: princessCol = Math.floor(BOARD_W / 3); break;
|
|
246
|
+
case 2: princessCol = Math.floor((2 * BOARD_W) / 3); break;
|
|
247
|
+
case 3: princessCol = Math.floor(BOARD_W / 4); break;
|
|
248
|
+
case 4: princessCol = Math.floor((3 * BOARD_W) / 4); break;
|
|
249
|
+
case 5: princessCol = cen + 4; break;
|
|
250
|
+
case 0:
|
|
251
|
+
default: princessCol = cen;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
return {
|
|
255
|
+
k, N, gap, amp, slopeEvery, slopePat: pat,
|
|
256
|
+
slopeDownFor: (i) => slopeDownFor(pat, i),
|
|
257
|
+
ladderCols: cols,
|
|
258
|
+
dkCol: clampInt(dkCol, lo, hi),
|
|
259
|
+
princessCol: clampInt(princessCol, lo, hi),
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
|
|
134
263
|
/** Girder index whose standing row is at-or-just-below row y at column x. */
|
|
135
264
|
function girderBelow(platforms, x, y) {
|
|
136
265
|
let best = -1, bestRow = Infinity;
|
|
@@ -182,34 +311,40 @@ export function initGame({
|
|
|
182
311
|
const { BOARD_W, BOARD_H } = boardSize(width, height);
|
|
183
312
|
if (BOARD_W < MIN_W || BOARD_H < MIN_H) return { tooSmall: true, BOARD_W, BOARD_H };
|
|
184
313
|
|
|
185
|
-
//
|
|
186
|
-
//
|
|
187
|
-
//
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
const
|
|
314
|
+
// Per-level layout: a PURE function of (level, BOARD_W, BOARD_H) — see
|
|
315
|
+
// levelLayout for the clamps that keep every knob within its invariant window.
|
|
316
|
+
// Fewer girders → bigger vertical gaps → real jump headroom (~4+ rows apart so
|
|
317
|
+
// the higher JUMP_VY reads as a tall jump); levelLayout's Nmax(BOARD_H) gate
|
|
318
|
+
// preserves that on small boards (N collapses to 3 exactly as the old gen did).
|
|
319
|
+
const layout = levelLayout(level, BOARD_W, BOARD_H);
|
|
320
|
+
const { N, gap, amp, slopeEvery } = layout;
|
|
191
321
|
const platforms = [];
|
|
192
322
|
for (let i = 0; i < N; i++) {
|
|
193
323
|
const baseRow = BOARD_H - 2 - amp - i * gap; // 0 = bottom-most girder
|
|
194
|
-
const down = i
|
|
195
|
-
platforms.push({ row: baseRow, slopeOffsets: buildSlope(baseRow, BOARD_W, down, amp) });
|
|
324
|
+
const down = layout.slopeDownFor(i);
|
|
325
|
+
platforms.push({ row: baseRow, slopeOffsets: buildSlope(baseRow, BOARD_W, down, amp, slopeEvery) });
|
|
196
326
|
}
|
|
197
327
|
// platforms[0] is the LOWEST (largest row); platforms[N-1] the HIGHEST.
|
|
198
328
|
|
|
329
|
+
// One ladder per adjacent pair, IN ORDER (ladders[i] connects platforms[i]→[i+1])
|
|
330
|
+
// so the autopilot's ladders[gi] assumption holds verbatim. The column comes from
|
|
331
|
+
// the layout (already clamped to [2,BOARD_W-3] + footprint-deconflicted); the
|
|
332
|
+
// endpoints are recomputed from the slope AT THAT column so both rails touch both
|
|
333
|
+
// standing rows even on sloped girders.
|
|
199
334
|
const ladders = [];
|
|
200
335
|
for (let i = 0; i < N - 1; i++) {
|
|
201
336
|
const lower = platforms[i];
|
|
202
337
|
const upper = platforms[i + 1];
|
|
203
|
-
const col =
|
|
338
|
+
const col = layout.ladderCols[i];
|
|
204
339
|
const yBottom = lower.slopeOffsets[col] - 1;
|
|
205
340
|
const yTop = upper.slopeOffsets[col] - 1;
|
|
206
341
|
ladders.push({ col, yTop: Math.min(yTop, yBottom), yBottom: Math.max(yTop, yBottom) });
|
|
207
342
|
}
|
|
208
343
|
|
|
209
344
|
const top = platforms[N - 1];
|
|
210
|
-
const dkCol =
|
|
345
|
+
const dkCol = layout.dkCol;
|
|
211
346
|
const donkeyKong = { x: dkCol, y: top.slopeOffsets[dkCol] - 1, throwCooldown: 2, animPhase: 0 };
|
|
212
|
-
const princessCol =
|
|
347
|
+
const princessCol = layout.princessCol;
|
|
213
348
|
const princess = { x: princessCol, y: top.slopeOffsets[princessCol] - 1, animPhase: 0 };
|
|
214
349
|
|
|
215
350
|
const player = makePlayer(platforms);
|
|
@@ -498,10 +633,24 @@ function stepPlaying(s, input, dt) {
|
|
|
498
633
|
}
|
|
499
634
|
} else {
|
|
500
635
|
// Grounded: follow the slope at the current column, detect walk-off.
|
|
636
|
+
// A sloped girder steps ±1 row every `slopeEvery` columns, so when walking
|
|
637
|
+
// INTO a riser the girder's stand row at the next column is one ABOVE the
|
|
638
|
+
// player's current cell (girderIndexAt at cell(py)+1 then misses → the
|
|
639
|
+
// player walks off the riser and falls — the critic's B1). Re-snap to the
|
|
640
|
+
// girder whose stand row is within ±1 of the player's cell so the player
|
|
641
|
+
// auto-mounts a one-row riser (and follows a one-row drop) instead of
|
|
642
|
+
// falling off. This is the same riser the player was already standing on
|
|
643
|
+
// (girders are >=2 rows apart, so at most one girder qualifies), so it
|
|
644
|
+
// never teleports between platforms — it just walks the staircase.
|
|
501
645
|
const c = cell(p.px);
|
|
502
|
-
const
|
|
646
|
+
const cy = cell(p.py);
|
|
647
|
+
// girder cell one below the player (flat / down-step → stand row stays cy).
|
|
648
|
+
let gi = girderIndexAt(platforms, c, cy + 1);
|
|
649
|
+
// up-step: the girder cell is AT the player's current row (stand row cy-1),
|
|
650
|
+
// so the next-column girder stepped up one — auto-mount it.
|
|
651
|
+
if (gi < 0) gi = girderIndexAt(platforms, c, cy);
|
|
503
652
|
if (gi >= 0) {
|
|
504
|
-
p.py = toFx(platforms[gi].slopeOffsets[c] - 1); // re-snap to slope
|
|
653
|
+
p.py = toFx(platforms[gi].slopeOffsets[c] - 1); // re-snap to slope (auto-mount the riser)
|
|
505
654
|
p.vy = 0;
|
|
506
655
|
} else {
|
|
507
656
|
// walked off the edge → coyote window, begin falling
|
|
@@ -686,5 +835,5 @@ export function deserialize(obj) {
|
|
|
686
835
|
// Expose internals for focused unit tests.
|
|
687
836
|
export const _internals = {
|
|
688
837
|
girderBelow, isGirderAt, girderIndexAt, ladderAt, rng, between,
|
|
689
|
-
makePlayer, advanceBarrels, syncCell,
|
|
838
|
+
makePlayer, advanceBarrels, syncCell, levelLayout, nMaxForHeight,
|
|
690
839
|
};
|