Something went wrong. Try again.
a tiny pet with a GPT-2 brain, living in your browser
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445import type { Generated, Generation } from "../types.ts";import { disturb, disturbances, resetDisturbances, setWakeRoll } from "./animation.ts";import { act } from "./care.ts";import { DEBUG } from "./config.ts";import { applyTags, petTurn, wantTurn } from "./conversation.ts";import { writeDiary } from "./diary.ts";import { simulate, stageFor } from "./simulation.ts";import { save } from "./storage.ts";import { brain, emit, store, toast, ui, upgrade, view } from "./store.ts";export function debugTurn(opts: Generation, result: Generated) { if (!DEBUG) return; ui.debugLog.push({ ...result, at: new Date(), mode: opts.mode }); if (ui.debugLog.length > 20) ui.debugLog.shift(); emit();}export function setAge(ms: number) { const pet = store.state.pet; if (!pet) return; pet.hatched = Date.now() - ms; pet.stage = stageFor(ms); save(); emit();}export const copyText = (text: string) => navigator.clipboard.writeText(text).then( () => toast("Copied."), () => toast("Couldn't copy."), );const debug = { setWakeRoll, disturb, disturbances, resetDisturbances, applyTags, simulate };export function testControls() { return { state: () => store.state, brain, view, act, petTurn, writeDiary, wantTurn, renderAll: emit, upgrade, ...(DEBUG ? { debug } : {}), };}export type TestControls = ReturnType<typeof testControls>;