Metabolism M2.8: rock — inert resource the song drops and builders quarry, carry and build with; livelier metabolisms

This commit is contained in:
Dejvino
2026-10-28 11:36:30 +01:00
parent 8abefb16b7
commit 1d497e556e
9 changed files with 464 additions and 30 deletions
+27 -10
View File
@@ -28,7 +28,8 @@ export const S_TIME = 8;
export const S_TOTAL = 9;
export const S_WELL = 10; // nearest living well's pull
export const S_PEACE = 11; // section's peace operator (war ↔ truce)
export const SENSE_COUNT = 12;
export const S_ROCK = 12; // rock under this block: the quarriable ground
export const SENSE_COUNT = 13;
// Gradient fields, two slots each (x, y): food, own strain, kin, foe, well.
export const G_FOOD = 0;
@@ -47,7 +48,9 @@ export const A_HIT = 4;
export const A_SPAWN = 5;
export const A_DRIFT = 6; // gradual direction change following a gradient
export const A_ACCELERATE = 7; // speed up / slow down
export const ACTION_COUNT = 8;
export const A_DIG = 8; // quarry rock here (rock → carried → soil)
export const A_BUILD = 9; // deposit carried rock as a wall
export const ACTION_COUNT = 10;
export const REGS = 6;
export const MAX_INSTR = 32;
@@ -89,23 +92,23 @@ class Asm {
const ROLES = {
builder: {
base: { speed: 0.030, deposit: 1.50, cap: 1.25, growth: 0.90, eat: 0.036 },
base: { speed: 0.038, deposit: 1.50, cap: 1.25, growth: 0.90, eat: 0.032 },
hungryAt: 0.50, spawnW: 0.30,
},
grazer: {
base: { speed: 0.075, deposit: 0.75, cap: 1.00, growth: 1.00, eat: 0.050 },
base: { speed: 0.095, deposit: 0.75, cap: 1.00, growth: 1.00, eat: 0.042 },
hungryAt: 0.42, spawnW: 0.45,
},
scout: {
base: { speed: 0.125, deposit: 0.18, cap: 0.80, growth: 1.05, eat: 0.055 },
base: { speed: 0.155, deposit: 0.18, cap: 0.80, growth: 1.05, eat: 0.046 },
hungryAt: 0.62, spawnW: 0.60,
},
sentinel: {
base: { speed: 0.058, deposit: 0.55, cap: 1.00, growth: 0.85, eat: 0.045 },
base: { speed: 0.070, deposit: 0.55, cap: 1.00, growth: 0.85, eat: 0.040 },
hungryAt: 0.50, spawnW: 0.25, foeAt: 0.10,
},
breeder: {
base: { speed: 0.050, deposit: 0.50, cap: 0.90, growth: 1.25, eat: 0.040 },
base: { speed: 0.062, deposit: 0.50, cap: 0.90, growth: 1.25, eat: 0.036 },
hungryAt: 0.55, spawnW: 0.85, kinAt: 0.12,
},
};
@@ -189,14 +192,25 @@ export function compileStrains(summary, genome, rng) {
const fed = asm.label();
asm.jump(hungryPatch, fed);
if (role === 'builder') {
// The ink-dropper: inscribes, but never quite stops — a slow orbit
// around its ground keeps the colony's edge alive.
asm.act(A_EXCRETE, 3, 1.35);
// The mason: where rock lies underfoot it quarries (rock becomes
// carried burden and, ground down, soil); where the ground is
// clear it walls — the carried rock rises as the colony's
// structure. It never quite stops orbiting its ground.
asm.sense(4, S_ROCK, 1);
const quarry = asm.ifgt(4, 0.12);
asm.act(A_BUILD, 1, 1.2);
asm.act(A_EXCRETE, 3, 1.1);
asm.grad(4, G_SELF, 0, 0.4);
asm.grad(5, G_SELF, 1, 0.4);
asm.act(A_DRIFT, 4, 0.8);
asm.act(A_SPAWN, 1, spec.spawnW);
asm.halt();
const dig = asm.label();
asm.jump(quarry, dig);
asm.act(A_DIG, 4, 1);
asm.grad(4, G_FOOD, 0, 0.3);
asm.act(A_MOVE_X, 4, 0.3);
asm.halt();
} else if (role === 'grazer') {
// Commutes: follows the food edge, leaves a road behind.
asm.grad(4, G_FOOD, 0, 0.7);
@@ -297,6 +311,7 @@ export function runProgram(memBuf, off, senses, grads, act, code) {
let steps = 0;
const n = code.length;
act[0] = 0; act[1] = 0; act[2] = 0; act[3] = 1; act[4] = 0; act[5] = 0;
act[6] = 0; act[7] = 0;
const mem = memBuf;
while (steps++ < MAX_STEPS && pc < n) {
const ins = code[pc];
@@ -334,6 +349,8 @@ export function runProgram(memBuf, off, senses, grads, act, code) {
case A_SPAWN: act[5] += Math.max(0, drive) * w * 0.012; break;
case A_DRIFT: act[0] += drive * w * 0.1; act[1] += drive * w * 0.1; break;
case A_ACCELERATE: act[3] *= drive * w + 1; break;
case A_DIG: act[6] += Math.max(0, drive) * w; break;
case A_BUILD: act[7] += Math.max(0, drive) * w; break;
default: break;
}
break;