Something went wrong. Try again.
a tiny pet with a GPT-2 brain, living in your browser
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354import * as Wd from "../world.ts";import { WANT_ICON } from "./config.ts";
export function chipsFor(text: string) { const chips: [string | null, string, string?][] = []; for (const m of text.matchAll(Wd.TAG_RE)) { const [, name, arg, res] = m; const r = res ? res.slice(1, -1) : ""; if (name === "clock") chips.push(["checked the clock", r]); else if (name === "look") chips.push(["looked around", r]); else if (name === "recall") chips.push([`tried to remember "${arg}"`, r]); else if (name === "yesterday") chips.push(["read yesterday's diary", r]); else if (name === "remember") chips.push(["saved a memory", arg]); else if (name === "gift") chips.push(["gave you a gift", arg, arg]); else if (name === "want") chips.push(["wants", arg, WANT_ICON[arg]]); else if (name === "diary") chips.push(["jotted in the diary", arg]); else if (name === "dream" && Wd.DREAMS.includes(arg)) chips.push([`dreams of ${Wd.dreamThing(arg)}`, "", arg]); else if (name === "sleep") chips.push(["fell asleep", ""]); else if (name === "yes") chips.push(["said yes", ""]); else if (name === "no") chips.push(["said no", ""]); else if (name === "emote" || name === "walk") chips.push([null, name === "walk" ? `walk-${arg}` : arg]); } return chips;}export const ACT_WORD: Record<string, string> = { happy: "bounces", love: "is in love", sad: "sniffles", sleepy: "yawns", wave: "waves", dance: "dances", spin: "spins", blush: "blushes", grumpy: "grumbles", wow: "gasps", giggle: "giggles", cry: "cries", "walk-left": "toddles left", "walk-right": "toddles right",};export function cleanText(text: string) { return text .replace(Wd.TAG_RE, " ") .replace(/[\[\]{}]/g, "") .replace(/\s+/g, " ") .trim();}
// GPT-2 learned from the open web; keep the pet's mouth clean regardless.export const NOT_CUTE = /\b(sex\w*|porn\w*|nude\w*|naked|panties|penis|vagina|cock|dick|pussy|boob\w*|tits?|fuck\w*|shit\w*|bitch\w*|cunt|whore|slut|rape\w*|nigg\w*|fag\w*|retard\w*|kill (you|yourself)|suicide)\b/i;