MCPcopy Create free account
hub / github.com/EvolvingPrograms/turing / evolve

Function evolve

programs/rule110/eval.ts:48–62  ·  view source on GitHub ↗
(state: Tape)

Source from the content-addressed store, hash-verified

46 }
47
48 function evolve(state: Tape) {
49 const newState: Tape = [];
50 if (typeof width === "string") width = parseInt(width);
51 for (let i = 0; i < width; i++) {
52 const left = i > 0 ? state[i - 1] : 0;
53 const center = state[i];
54 const right = i < width - 1 ? state[i + 1] : 0;
55
56 const pattern: TapeValue = applyRule110(left, center, right);
57 log(`${i-1}${format([left])} ${i}${format([center])} ${i+1}${format([right])} ${pattern}`)
58 newState.push(pattern);
59 }
60
61 return newState;
62 }
63
64 console.log(`\nUSER:\n${state.join(" ")}\n${width}\n${generations}`)
65 console.log("\nASSISTANT:")

Callers 1

rule_110Function · 0.85

Calls 3

applyRule110Function · 0.85
logFunction · 0.85
formatFunction · 0.85

Tested by

no test coverage detected