feat(v4): Phase 7 Task 4 -- the loops' words: v3's physics-freeze and inference words, F18 asking the kernel (#189)
capsules/v4/physics.4th, a kernel capsule on Hera (blocks 8200-8201): FREEZE-WORD UNFREEZE-WORD FROZEN? HEAT! HEAT@ DECAY-RATE@ Q.VARIANCE INFER-DECAY-SLOPE INFER-WINDOW-WIDTH INFER-RUN INFER-WINDOW@ INFER-DECAY@ INFER-VARIANCE@ INFER-FIT@ INFER-EARLY-EXIT@ -- each a KERNEL-WORD, requests -21..-34 (v4/mesh.h), served by the kernel on any node: "The compudynamics is stadium/fabric" (Captain Bob, 2026-11-14). A word is named as v3's, the newest visible entry of CONTEXT then FORTH (the image gains CONTEXT's address); the arithmetic is v4/system/inference.c, v3's to the bit. Q48.16 results are v4's doubles (low cell, then high). HEAT! starts the word's decay from now. Test first with v3's POST cases in v4's address units: test_mesh_boot.c 86 checks, 95 on, 83 without opcode physics. docs/reference/v4-dictionary.tsv: the 15 words (392 live). amd64 PASS, word_count=392. Not pushed (held to the end of Phase 7). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
Block 8200
|
||||
( physics.4th -- the words of the loops, v3's physics-freeze )
|
||||
( and inference words, on a node the kernel keeps records )
|
||||
( for: each asks its kernel, which keeps every word's and )
|
||||
( opcode's physics and does the arithmetic -- compudynamics )
|
||||
( is the Stadium/fabric's: #189 Phase 7, Task 4, Captain Bob )
|
||||
( 2026-11-14. The requests, by their numbers in v4/mesh.h: )
|
||||
-21 KERNEL-WORD FREEZE-WORD ( baddr u -- )
|
||||
-22 KERNEL-WORD UNFREEZE-WORD ( baddr u -- )
|
||||
-23 KERNEL-WORD FROZEN? ( baddr u -- flag )
|
||||
-24 KERNEL-WORD HEAT! ( n baddr u -- )
|
||||
-25 KERNEL-WORD HEAT@ ( baddr u -- n )
|
||||
-26 KERNEL-WORD Q.VARIANCE ( addr u -- d )
|
||||
-27 KERNEL-WORD INFER-DECAY-SLOPE ( addr u -- d )
|
||||
-28 KERNEL-WORD INFER-WINDOW-WIDTH ( addr u -- n )
|
||||
-29 KERNEL-WORD INFER-RUN ( -- )
|
||||
Block 8201
|
||||
( and what the last INFER-RUN, or the heartbeat's, found; )
|
||||
( a q is a Q48.16 double, as qmath.f18's )
|
||||
-30 KERNEL-WORD INFER-WINDOW@ ( -- u )
|
||||
-31 KERNEL-WORD INFER-DECAY@ ( -- d )
|
||||
-32 KERNEL-WORD INFER-VARIANCE@ ( -- d )
|
||||
-33 KERNEL-WORD INFER-FIT@ ( -- d )
|
||||
-34 KERNEL-WORD INFER-EARLY-EXIT@ ( -- flag )
|
||||
( v3's DECAY_RATE_PER_US_Q16, its compile-time constant )
|
||||
1 CONSTANT DECAY-RATE@
|
||||
@@ -141,6 +141,7 @@ D2/ ( d1 -- d2 ) Shift d1 right one bit, keeping the sign.
|
||||
D< ( d1 d2 -- flag ) True if d1 is less than d2.
|
||||
D= ( d1 d2 -- flag ) True if d1 equals d2.
|
||||
DABS ( d -- ud ) The absolute value of d.
|
||||
DECAY-RATE@ ( -- n ) v3's DECAY_RATE_PER_US_Q16, its compile-time constant: 1.
|
||||
DECIMAL ( -- ) Set BASE to ten.
|
||||
DEFAULT-ROUTE ( port -- ) The port, by its number, leads toward every node this node has not been told of.
|
||||
DEFER ( -- ) DEFER xxx: define xxx, whose action is set later by IS; run unset, it is error 15.
|
||||
@@ -172,8 +173,12 @@ FIND ( -- xt | 0 ) FIND xxx: the execution token of xxx, from the input stream,
|
||||
FLUSH ( -- ) Write every changed block (SAVE-BUFFERS).
|
||||
FORGET ( -- ) FORGET xxx: remove xxx and every word defined after it, never below FENCE.
|
||||
FORTH ( -- ) Make FORTH, the primary vocabulary, the CONTEXT vocabulary.
|
||||
FREEZE-WORD ( baddr u -- ) The word named stops decaying (its record frozen, in the kernel). Nothing if there is no such word.
|
||||
FROZEN? ( baddr u -- flag ) True if the word named is frozen; false for one that is not, or is not there.
|
||||
GONE ( n node -- ) Tell the node that node n is gone; it acts on that only if this node is its centre.
|
||||
HEAT! ( n baddr u -- ) The heat of the word named, in the kernel's record of it, set to n; its decay counts from now.
|
||||
HEAT-OP@ ( op -- n ) How many times opcode op (taken mod 32) has retired: its heat counter, HEAT-OP[op] (#189).
|
||||
HEAT@ ( baddr u -- n ) The heat of the word named, from the kernel's record of it; 0 if there is no such word.
|
||||
HERE ( -- addr ) The address of the next free dictionary cell.
|
||||
HEX ( -- ) Set BASE to sixteen.
|
||||
HIDDEN ( -- ) Hide the newest entry: it cannot be found until revealed.
|
||||
@@ -181,6 +186,14 @@ HOLD ( c -- ) Pictured output: put the character c in front of the string being
|
||||
I ( -- n ) Compile-only: the index of the innermost DO loop.
|
||||
IF ( flag -- ) Compile-only: run what follows if flag is not zero, else skip to ELSE or THEN.
|
||||
IMMEDIATE ( -- ) Make the newest definition run when compiling instead of being compiled.
|
||||
INFER-DECAY-SLOPE ( addr u -- d ) The decay slope of u cells of heat at addr, as Q48.16 (a log-linear regression, as v3's).
|
||||
INFER-DECAY@ ( -- d ) The decay slope inference last found, as Q48.16.
|
||||
INFER-EARLY-EXIT@ ( -- flag ) 1 if the last inference exited early, its variance within 5% of the time before.
|
||||
INFER-FIT@ ( -- d ) The fit of the last decay slope, as Q48.16 (v3's: 0.8 always, a placeholder).
|
||||
INFER-RUN ( -- ) Run the inference engine now on this node's rolling window; what it finds is read with the INFER-...@ words.
|
||||
INFER-VARIANCE@ ( -- d ) The window's variance when inference last ran, as Q48.16.
|
||||
INFER-WINDOW-WIDTH ( addr u -- n ) The window width at which the variance of u cells at addr stops changing (Levene's test, as v3's).
|
||||
INFER-WINDOW@ ( -- u ) The window width inference last found.
|
||||
INTERPRET ( -- ) Interpret words from the input stream until it is exhausted.
|
||||
INVERT ( x1 -- x2 ) Invert every bit.
|
||||
IS ( xt -- ) IS xxx: make the deferred word xxx run xt; compiled when compiling.
|
||||
@@ -265,6 +278,7 @@ Q.SCALE ( -- q ) The scale of the fraction, 65536 0 (1.0).
|
||||
Q.SIN ( q1 -- q2 ) The sine of q1, in radians.
|
||||
Q.SQRT ( q1 -- q2 ) The square root of q1; below zero is error 12.
|
||||
Q.TO-INT ( q -- n ) The integer part of q.
|
||||
Q.VARIANCE ( addr u -- d ) The variance of u cells at addr, as Q48.16, computed by the kernel as v3's inference engine does.
|
||||
QUERY ( -- ) Read up to 80 characters, or a line, from the terminal into TIB; set >IN to 0.
|
||||
QUIT ( -- ) Empty the return stack, set execution mode and go back to the terminal, without a message.
|
||||
R> ( -- x ) ( R: x -- ) Compile-only: move the top of the return stack to the data stack.
|
||||
@@ -304,6 +318,7 @@ U/MOD ( ud u1 -- u2 u3 ) Unsigned divide: u2 the remainder, u3 the quotient; by
|
||||
U< ( u1 u2 -- flag ) True if u1 is less than u2, unsigned.
|
||||
U> ( u1 u2 -- flag ) True if u1 is greater than u2, unsigned.
|
||||
UM* ( u1 u2 -- ud ) Multiply, unsigned: the double-cell product.
|
||||
UNFREEZE-WORD ( baddr u -- ) The word named decays again. Nothing if there is no such word.
|
||||
UNLOOP ( -- ) Compile-only: discard the innermost DO loop's index and limit, before an EXIT from inside it.
|
||||
UNTIL ( flag -- ) Compile-only: end a BEGIN loop, jumping back to BEGIN while flag is zero.
|
||||
UPDATE ( -- ) Mark the block most recently asked for as changed, so it is written.
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 10 and column 3.
|
@@ -169,6 +169,17 @@ Phase 4).
|
||||
- [x] Measured, back to back on amd64: 219 s on, 196 s off -- about +12% under TCG. Kept, as ruled; the
|
||||
revert is the one switch.
|
||||
### Task 4: the words that read and set them (`FREEZE-WORD`, the inference words, ...), and their POST
|
||||
- [x] `capsules/v4/physics.4th` (blocks 8200-8201), a kernel capsule on Hera: v3's physics-freeze words
|
||||
(`FREEZE-WORD` `UNFREEZE-WORD` `FROZEN?` `HEAT!` `HEAT@` `DECAY-RATE@`) and inference words
|
||||
(`Q.VARIANCE` `INFER-DECAY-SLOPE` `INFER-WINDOW-WIDTH` `INFER-RUN` `INFER-WINDOW@` `INFER-DECAY@`
|
||||
`INFER-VARIANCE@` `INFER-FIT@` `INFER-EARLY-EXIT@`), each `KERNEL-WORD` -- requests -21 to -34, which the
|
||||
kernel serves on any node ("compudynamics is stadium/fabric"): a word named as v3's, by the newest
|
||||
visible entry of CONTEXT then FORTH; the arithmetic `v4/system/inference.c`'s. A Q48.16 result is v4's
|
||||
double (qmath.f18: low cell, then high). `HEAT!` starts the word's decay from now (a word never
|
||||
touched would otherwise decay at once by every tick since its definition). Test first, v3's POST
|
||||
cases with v4's address units (`test_mesh_boot.c`: 86 checks; 95 on; 83 without opcode physics).
|
||||
- [ ] The entropy and top-words words (`starforth_words_test.c`): `ENTROPY!` `ENTROPY@` `RESET-ENTROPY`
|
||||
`TOP-WORDS` `WORD-ENTROPY`.
|
||||
### Task 5: the StarForth words (Phase 3's: `init.4th`, `starforth.4th`), and their POST
|
||||
### Task 6: the ACL (Phase 4's: `ACL.4th`, the word card, the countdown), and its POST
|
||||
### Task 7: the block cases (Phase 5's part)
|
||||
|
||||
@@ -151,7 +151,7 @@ static void sk_v4_parity(void *self, unsigned place, v4_cell number, const v4_no
|
||||
line[at] = 0;
|
||||
console_println(line);
|
||||
}
|
||||
static const char *const sk_v4_capsules[] = { "v4:centre.4th", "v4:hera.4th" };
|
||||
static const char *const sk_v4_capsules[] = { "v4:centre.4th", "v4:hera.4th", "v4:physics.4th" };
|
||||
|
||||
static char sk_v4_text[SK_V4_LINE + 1u];
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
Development boot, not acceptance evidence (2026-11-14): amd64 with #189 Phase 7 Task 4 -- capsules/v4/physics.4th, the loops' words, loaded on Hera. RESULT: PASS; POST 539/539; word_count=392; CONSERVED.
|
||||
Binary file not shown.
@@ -76,6 +76,9 @@ typedef struct {
|
||||
* the dictionary. The kernel fills it, when its build has ENABLE_HOTWORDS_CACHE; otherwise it is empty. */
|
||||
v4_cell hot;
|
||||
|
||||
/* CONTEXT: the variable that holds the address of the vocabulary names are looked up in first (dict.f18) */
|
||||
v4_cell context;
|
||||
|
||||
/* the block window: the word address of the slots the kernel copies
|
||||
* blocks into (v4/blocks.h) */
|
||||
v4_cell block_window;
|
||||
|
||||
@@ -53,6 +53,22 @@
|
||||
#define V4_MESH_WORD_IDS 1024u /* word IDs a record is kept for: v3's DICTIONARY_SIZE, the Stadium's bound */
|
||||
#define V4_REQ_WORD_DEFINED (-19)
|
||||
#define V4_REQ_WORD_FORGOTTEN (-20)
|
||||
/* the loops' words (capsules/v4/physics.4th; #189 Phase 7, Task 4): a word named by (baddr u), as v3's, or cells
|
||||
* of the node's memory (addr u) */
|
||||
#define V4_REQ_FREEZE_WORD (-21) /* ( baddr u -- ) */
|
||||
#define V4_REQ_UNFREEZE_WORD (-22) /* ( baddr u -- ) */
|
||||
#define V4_REQ_FROZEN (-23) /* ( baddr u -- flag ) */
|
||||
#define V4_REQ_HEAT_STORE (-24) /* ( n baddr u -- ) */
|
||||
#define V4_REQ_HEAT_FETCH (-25) /* ( baddr u -- n ) */
|
||||
#define V4_REQ_Q_VARIANCE (-26) /* ( addr u -- q ) */
|
||||
#define V4_REQ_INFER_SLOPE (-27) /* ( addr u -- q ) */
|
||||
#define V4_REQ_INFER_WIDTH (-28) /* ( addr u -- n ) */
|
||||
#define V4_REQ_INFER_RUN (-29) /* ( -- ) */
|
||||
#define V4_REQ_INFER_WINDOW (-30) /* ( -- u ) */
|
||||
#define V4_REQ_INFER_DECAY (-31) /* ( -- q ) */
|
||||
#define V4_REQ_INFER_VARIANCE (-32) /* ( -- q ) */
|
||||
#define V4_REQ_INFER_FIT (-33) /* ( -- q ) */
|
||||
#define V4_REQ_INFER_EARLY (-34) /* ( -- flag ) */
|
||||
typedef struct {
|
||||
v4_uheat_t calls; /* every call since the word was defined */
|
||||
v4_uheat_t since; /* calls since the owner last charged them */
|
||||
|
||||
@@ -819,6 +819,107 @@ void v4_mesh_charge(v4_mesh *ms, unsigned place, void (*each)(void *ctx, v4_cell
|
||||
}
|
||||
}
|
||||
|
||||
/* ---- the loops' words (capsules/v4/physics.4th) ---- */
|
||||
|
||||
static unsigned byte_at(const v4_node *n, v4_cell baddr) /* four to a cell, low byte first (D-1) */
|
||||
{
|
||||
v4_cell w = baddr >> 2;
|
||||
if (baddr < 0 || w >= (v4_cell)V4_NODE_WORDS) return 0;
|
||||
return (unsigned)(((v4_ucell)n->mem[w] >> (8u * (unsigned)(baddr & 3))) & 0xFFu);
|
||||
}
|
||||
|
||||
/* the newest visible entry named by (baddr u) -- CONTEXT's vocabulary, then FORTH, as (LOOKUP) -- or 0 */
|
||||
static v4_cell word_named(const v4_node *n, v4_cell baddr, v4_cell u)
|
||||
{
|
||||
v4_cell heads[2], xt;
|
||||
unsigned h, k, len = u > 31 ? 31u : (unsigned)u;
|
||||
if (u <= 0) return 0;
|
||||
heads[0] = n->mem[n->mem[the->im->context]];
|
||||
heads[1] = n->mem[the->im->latest];
|
||||
for (h = 0; h < 2; h++) {
|
||||
for (xt = heads[h], k = 0; xt > 4 && xt < (v4_cell)V4_NODE_WORDS && k < V4_NODE_WORDS; xt = n->mem[xt - 1], k++) {
|
||||
v4_cell nfa = n->mem[xt - 2];
|
||||
unsigned i, ok = 1;
|
||||
if (n->mem[xt - 3] & 2) continue; /* hidden */
|
||||
if (byte_at(n, nfa * 4) != len) continue;
|
||||
for (i = 0; i < len && ok; i++) if (byte_at(n, nfa * 4 + 1 + (v4_cell)i) != byte_at(n, baddr + (v4_cell)i)) ok = 0;
|
||||
if (ok) return xt;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* u cells of the node's memory at addr, as v3's array of 64-bit heats (0 if out of range) */
|
||||
static const uint64_t *cells_at(const v4_node *n, v4_cell addr, v4_cell u)
|
||||
{
|
||||
static uint64_t buf[V4_MESH_WINDOW];
|
||||
v4_cell i;
|
||||
if (u <= 0 || u > (v4_cell)V4_MESH_WINDOW || addr < 0 || addr + u > (v4_cell)V4_NODE_WORDS) return 0;
|
||||
for (i = 0; i < u; i++) buf[i] = (uint64_t)(v4_ucell)n->mem[addr + i];
|
||||
return buf;
|
||||
}
|
||||
|
||||
/* a Q48.16 value as v4's: a double, low cell then high (qmath.f18: Q.1 is 65536 0), at either cell width */
|
||||
static void push_q(v4_node *n, uint64_t q)
|
||||
{
|
||||
#if V4_CELL_BITS >= 64
|
||||
v4_dstack_push(&n->ds, (v4_cell)q);
|
||||
v4_dstack_push(&n->ds, 0);
|
||||
#else
|
||||
v4_dstack_push(&n->ds, (v4_cell)(v4_ucell)(q & 0xFFFFFFFFu));
|
||||
v4_dstack_push(&n->ds, (v4_cell)(v4_ucell)(q >> 32));
|
||||
#endif
|
||||
}
|
||||
|
||||
static int physics_serve(unsigned place, v4_node *n, v4_cell value)
|
||||
{
|
||||
v4_mesh_physics *p = the->physics ? &the->physics[place] : 0;
|
||||
v4_cell u, a, xt;
|
||||
v4_mesh_account *r;
|
||||
const uint64_t *d;
|
||||
if (value > V4_REQ_FREEZE_WORD || value < V4_REQ_INFER_EARLY) return 0;
|
||||
switch (value) {
|
||||
case V4_REQ_FREEZE_WORD: case V4_REQ_UNFREEZE_WORD: case V4_REQ_FROZEN: case V4_REQ_HEAT_FETCH: case V4_REQ_HEAT_STORE:
|
||||
u = v4_dstack_pop(&n->ds); a = v4_dstack_pop(&n->ds);
|
||||
xt = word_named(n, a, u);
|
||||
r = xt ? (v4_mesh_account *)v4_mesh_account_at(the, place, xt) : 0;
|
||||
if (value == V4_REQ_FREEZE_WORD) { if (r) r->state_flags |= V4_MESH_STATE_FROZEN; }
|
||||
else if (value == V4_REQ_UNFREEZE_WORD) { if (r) r->state_flags &= (uint8_t)~V4_MESH_STATE_FROZEN; }
|
||||
else if (value == V4_REQ_FROZEN) v4_dstack_push(&n->ds, r && (r->state_flags & V4_MESH_STATE_FROZEN) ? -1 : 0);
|
||||
else if (value == V4_REQ_HEAT_FETCH) v4_dstack_push(&n->ds, r ? (v4_cell)r->heat : 0);
|
||||
else { /* the heat stored is its heat now: decay counts from here */
|
||||
v4_cell heat = v4_dstack_pop(&n->ds);
|
||||
if (r) { r->heat = (v4_uheat_t)heat; if (p) r->last_decay_tick = p->tick; }
|
||||
}
|
||||
return 1;
|
||||
case V4_REQ_Q_VARIANCE: case V4_REQ_INFER_SLOPE: case V4_REQ_INFER_WIDTH:
|
||||
u = v4_dstack_pop(&n->ds); a = v4_dstack_pop(&n->ds);
|
||||
d = cells_at(n, a, u);
|
||||
if (value == V4_REQ_Q_VARIANCE) push_q(n, d ? v4_inference_variance(d, (uint64_t)u) : 0);
|
||||
else if (value == V4_REQ_INFER_SLOPE) push_q(n, d ? v4_inference_decay_slope(d, (uint64_t)u) : 0);
|
||||
else v4_dstack_push(&n->ds, d ? (v4_cell)v4_inference_window_width(d, (uint64_t)u) : 0);
|
||||
return 1;
|
||||
case V4_REQ_INFER_RUN: /* v3's: the engine run now on the window, outputs kept */
|
||||
if (p) {
|
||||
uint64_t have = p->win.total_executions < V4_MESH_WINDOW ? p->win.total_executions : V4_MESH_WINDOW;
|
||||
uint64_t span = p->win.effective_window_size < have ? p->win.effective_window_size : have, i;
|
||||
for (i = 0; i < span; i++) {
|
||||
uint32_t id = p->win.history[(p->win.window_pos + V4_MESH_WINDOW - span + i) % V4_MESH_WINDOW];
|
||||
trajectory[i] = (id < V4_MESH_WORD_IDS && accounts_of(place)[id].xt) ? (uint64_t)accounts_of(place)[id].heat : 0;
|
||||
}
|
||||
v4_inference_run(trajectory, span, p->l5_window_inference, p->l6_decay_inference, &p->inference);
|
||||
}
|
||||
return 1;
|
||||
default:
|
||||
if (value == V4_REQ_INFER_DECAY) push_q(n, p ? p->inference.adaptive_decay_slope : 0);
|
||||
else if (value == V4_REQ_INFER_VARIANCE) push_q(n, p ? p->inference.window_variance_q48 : 0);
|
||||
else if (value == V4_REQ_INFER_FIT) push_q(n, p ? p->inference.slope_fit_quality_q48 : 0);
|
||||
else if (value == V4_REQ_INFER_WINDOW) v4_dstack_push(&n->ds, p ? (v4_cell)p->inference.adaptive_window_width : 0);
|
||||
else v4_dstack_push(&n->ds, p ? (v4_cell)p->inference.early_exited : 0);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
static int kernel_take(void *self, v4_cell value) /* a request */
|
||||
{
|
||||
unsigned place = place_of_device(self);
|
||||
@@ -827,6 +928,7 @@ static int kernel_take(void *self, v4_cell value) /* a request */
|
||||
if (v4_blocks_serve(&the->blocks[place], &x->n, value)) return 1;
|
||||
if (value == V4_REQ_WORD_DEFINED) { word_made(place, &x->n, v4_dstack_pop(&x->n.ds)); return 1; }
|
||||
if (value == V4_REQ_WORD_FORGOTTEN) { words_gone(place, &x->n, v4_dstack_pop(&x->n.ds)); return 1; }
|
||||
if (physics_serve(place, &x->n, value)) return 1;
|
||||
if (place == the->hera_place && the->serve && value >= 1 && value <= (v4_cell)the->word_count) {
|
||||
the->serve(&x->n, (unsigned)value);
|
||||
return 1;
|
||||
|
||||
@@ -81,7 +81,7 @@ static int key(void) { return V4_BOOT_KEY_END; }
|
||||
static const char *const words[] = { "BYE" };
|
||||
static unsigned served;
|
||||
static void serve(v4_node *n, unsigned request) { (void)n; if (request == 1) served++; }
|
||||
static const char *const capsules[] = { "v4:centre.4th", "v4:hera.4th" };
|
||||
static const char *const capsules[] = { "v4:centre.4th", "v4:hera.4th", "v4:physics.4th" };
|
||||
|
||||
static unsigned char ram[(size_t)BLK_RAM_BLOCKS * BLK_FORTH_SIZE];
|
||||
extern void sf_time_init(void);
|
||||
@@ -110,7 +110,7 @@ int main(void)
|
||||
ms.reg = reg; ms.blocks = blocks; ms.nucleus = &nucleus; ms.hera = &hera; ms.kernel = kernel;
|
||||
ms.room = room; ms.unroom = unroom; ms.born = born; ms.gone = gone; ms.parity = parity;
|
||||
ms.out = out; ms.key = key; ms.words = words; ms.word_count = 1; ms.serve = serve;
|
||||
ms.capsules = capsules; ms.capsule_count = 2; ms.im = &im; ms.self = 0;
|
||||
ms.capsules = capsules; ms.capsule_count = 3; ms.im = &im; ms.self = 0;
|
||||
ms.accounts = accounts; ms.is_word = is_word; ms.forgot = forgot;
|
||||
ms.physics = physics; ms.alloc = alloc; ms.release = release; ms.heartrate = heartrate;
|
||||
|
||||
@@ -218,6 +218,38 @@ int main(void)
|
||||
r = line(V4_MESH_HERA, "FORGET L8T", &how);
|
||||
}
|
||||
|
||||
/* ---- the loops' words (#189 Phase 7, Task 4): v3's physics-freeze and inference words, F18 asking the kernel,
|
||||
* which keeps the records and does the arithmetic (Captain Bob, 2026-11-14: "The compudynamics is
|
||||
* stadium/fabric"). v3's POST cases, with v4's address units (a cell is one) ---- */
|
||||
{
|
||||
r = line(V4_MESH_HERA, ": FT1 ; S\" FT1\" FREEZE-WORD S\" FT1\" FROZEN? .", &how);
|
||||
CHECK(how == V4_TEXT_COMPLETED && strcmp(r, "-1 ") == 0, "FREEZE-WORD, then FROZEN?: -1 (\"%s\")", r);
|
||||
r = line(V4_MESH_HERA, "S\" FT1\" UNFREEZE-WORD S\" FT1\" FROZEN? .", &how);
|
||||
CHECK(strcmp(r, "0 ") == 0, "UNFREEZE-WORD: 0 (\"%s\")", r);
|
||||
r = line(V4_MESH_HERA, ": FT2 ; S\" FT2\" FROZEN? . S\" __nonexistent_xyz__\" FROZEN? .", &how);
|
||||
CHECK(strcmp(r, "0 0 ") == 0, "a fresh word is not frozen, and nor is one not found (\"%s\")", r);
|
||||
r = line(V4_MESH_HERA, ": HT1 ; 999 S\" HT1\" HEAT! S\" HT1\" HEAT@ . : HT2 ; S\" HT2\" HEAT@ .", &how);
|
||||
CHECK(strcmp(r, "999 0 ") == 0, "HEAT! 999 then HEAT@: 999; a fresh word's: 0 (\"%s\")", r);
|
||||
r = line(V4_MESH_HERA, "DECAY-RATE@ .", &how);
|
||||
CHECK(strcmp(r, "1 ") == 0, "DECAY-RATE@: v3's DECAY_RATE_PER_US_Q16, 1 (\"%s\")", r);
|
||||
{
|
||||
uint64_t d3[3] = { 100, 200, 300 }, u3[3] = { 300, 200, 100 };
|
||||
char want[64];
|
||||
r = line(V4_MESH_HERA, "100 HERE ! 200 HERE 1 + ! 300 HERE 2 + ! HERE 3 Q.VARIANCE Q.TO-INT .", &how);
|
||||
snprintf(want, sizeof want, "%lu ", (unsigned long)(v4_inference_variance(d3, 3) >> 16));
|
||||
CHECK(strcmp(r, want) == 0, "Q.VARIANCE of 100 200 300: \"%s\" (v3's engine: \"%s\")", r, want);
|
||||
r = line(V4_MESH_HERA, "300 HERE ! 200 HERE 1 + ! 100 HERE 2 + ! HERE 3 INFER-DECAY-SLOPE Q.TO-INT .", &how);
|
||||
snprintf(want, sizeof want, "%lu ", (unsigned long)(v4_inference_decay_slope(u3, 3) >> 16));
|
||||
CHECK(strcmp(r, want) == 0, "INFER-DECAY-SLOPE of 300 200 100: \"%s\" (\"%s\")", r, want);
|
||||
r = line(V4_MESH_HERA, "100 HERE ! 200 HERE 1 + ! 300 HERE 2 + ! HERE 3 INFER-WINDOW-WIDTH .", &how);
|
||||
snprintf(want, sizeof want, "%u ", v4_inference_window_width(d3, 3));
|
||||
CHECK(strcmp(r, want) == 0, "INFER-WINDOW-WIDTH of 100 200 300: \"%s\" (\"%s\")", r, want);
|
||||
}
|
||||
r = line(V4_MESH_HERA, "INFER-RUN INFER-WINDOW@ . INFER-DECAY@ Q.TO-INT . INFER-VARIANCE@ Q.TO-INT . INFER-FIT@ Q.TO-INT . INFER-EARLY-EXIT@ .", &how);
|
||||
CHECK(how == V4_TEXT_COMPLETED && strstr(r, "ERROR") == 0, "INFER-RUN and its five readings, with no error: \"%s\"", r);
|
||||
r = line(V4_MESH_HERA, "FORGET FT1", &how);
|
||||
}
|
||||
|
||||
/* ---- the opcodes (#189 Phase 7, ruling 7: every loop on the 32 F18 opcodes too; revert: OPCODE_PHYSICS 0) ---- */
|
||||
{
|
||||
v4_mesh_physics *p = &ms.physics[0];
|
||||
|
||||
+2
-2
@@ -53,10 +53,10 @@ static int image_description(void)
|
||||
printf("#include \"v4/image.h\"\n\nconst v4_image v4_map_image = {\n");
|
||||
printf(" %uu, %uu, %uu, %uu,\n", (unsigned)V4_CELL_BITS, (unsigned)V4_NODE_WORDS, (unsigned)V4_DATA_RING, (unsigned)V4_RET_RING);
|
||||
printf(" -1,\n -1, %ld,\n -1, -1,\n", (long)PORT);
|
||||
printf(" %ld, %ld, %ld,\n %ld, %ld,\n %ld,\n %ld, %ld,\n %ld, %ld,\n %ld, %ld,\n %ld, %ld,\n %ld, %ld,\n %ld,\n %ld,\n",
|
||||
printf(" %ld, %ld, %ld,\n %ld, %ld,\n %ld,\n %ld, %ld,\n %ld, %ld,\n %ld, %ld,\n %ld, %ld,\n %ld, %ld,\n %ld,\n %ld,\n %ld,\n",
|
||||
(long)CONSOLE_TX, (long)CONSOLE_RX, (long)CONSOLE_ST, (long)DSTACK_REG, (long)RSTACK_REG,
|
||||
(long)NODE_ERROR, (long)HEAT_REG, (long)ME, (long)DP, (long)LATEST, (long)BOOT_CELLS, (long)FENCE,
|
||||
(long)NEXT_ID, (long)BOOT_ID, (long)WORD_DEFINED, (long)WORD_FORGOTTEN, (long)HOTVARS, (long)BUF0_W);
|
||||
(long)NEXT_ID, (long)BOOT_ID, (long)WORD_DEFINED, (long)WORD_FORGOTTEN, (long)HOTVARS, (long)CONTEXT, (long)BUF0_W);
|
||||
printf(" %ld, %ld, %ld\n};\n", (long)ROM_IMG, (long)ROM_FAILED, (long)ROM_ERRLINE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user