import { useState } from "preact/hooks"; import { disturbanceCount } from "../app/animation.ts"; import { offerThing } from "../app/care.ts"; import { DAY, MIN, STAGE_AGE } from "../app/config.ts"; import { copyText, setAge } from "../app/debug.ts"; import { writeDiary } from "../app/diary.ts"; import { age, dayNum, worldState } from "../app/simulation.ts"; import { save } from "../app/storage.ts"; import { brain, emit, store, ui, view } from "../app/store.ts"; import type { Disturbance, Stat } from "../types.ts"; import { header, wakeChance } from "../world.ts"; export function Debug() { const s = store.state, pet = s.pet; const [days, setDays] = useState(() => (age() / DAY).toFixed(2)); const n = disturbanceCount() + 1; return ( <>

Pet

{pet ? ( <>

{`brain ${brain.id || "none"} · ${pet.stage}, day ${dayNum()} (${(age() / DAY).toFixed(2)} days old) · offer open: ${s.offer ? offerThing(s.offer) : "none"}`}

{STAGE_AGE.slice() .reverse() .map(([stage, ms]) => ( ))}
setDays(e.currentTarget.value)} />
{(Object.keys(s.stats) as Stat[]).map((k) => (
{ s.stats[k] = +e.currentTarget.value; save(); emit(); }} /> {Math.round(s.stats[k])}
))}

{`${s.asleep ? "Asleep" : "Awake"} · next disturbance #${n}: `} {(["talk", "touch", "light"] as Disturbance[]) .map((k) => `${k} ${Math.round(wakeChance(s.stats.energy, k, n) * 100)}%`) .join(" · ")}

Write today's page using the log so far, even if it is short. An early page skips bedtime writing; rewrite it later to include new events.

) : (

No pet yet.

)}

Context

The last prompts sent to the brain, newest first; what it wrote is highlighted. Only kept until the page reloads.

{ui.debugLog .slice() .reverse() .map((d) => (
{`${d.at.toLocaleTimeString()} · ${d.mode} · ${d.promptTokens} prompt tokens · stopped: ${d.reason}`}
              {d.prompt}
              {d.text}
            
))} ); }