# gizgame/mind

The minds of an online world (gizgame/online Realm.minds). Each being a Persona names is an agent (gizai/agent): who it is, how it feels and what it thinks of each one it met are its instructions; what it heard, said and did is its conversation, which the agent compacts into the being's own memory as it grows; the verbs (Verb) are its tools, which the server's fast layer runs each tick. The director is the agent of the world itself: a builder's words become world edits through the same verbs, and it finds a thing in the public catalogs (gizlang/catalog) or makes a new one. A model is any that Agent.named names: giz.ai's, GizStack's, or one a server of this network runs ("NAME@URL"). The agents run on threads of their own: a tick only hands asks over and takes the thoughts that came back; it never waits for a model.

```gizlang
import * as Mind from "gizgame/mind";
```

## Types

### `Persona`

```gizlang
type Persona = { kind: string; name: string; role: string; traits: string; knows?: string; goals?: Vec<string>; voice?: string; sells?: Vec<Ware>; }
```

Who a being of KIND is: its NAME, its ROLE in the world, its TRAITS (how it is and how it talks), what it KNOWS
that others may ask, and the GOALS it pursues on its own. VOICE names its voice among the voices of the realm's
voice model (Minds.voice); with none it speaks in text alone. It SELLS its wares to players (Ware). The first being
of KIND not yet given a persona takes it.

- `kind`: `string`
- `name`: `string`
- `role`: `string`
- `traits`: `string`
- `knows`: `_gizlang_sdk_core.Option<string>`
- `goals`: `_gizlang_sdk_core.Option<Vec<string>>`
- `voice`: `_gizlang_sdk_core.Option<string>`
- `sells`: `_gizlang_sdk_core.Option<Vec<M191.Ware>>`

### `Ware`

```gizlang
type Ware = { item: string; price: i64; }
```

An item of the realm (Realm.items, by name) a persona sells, for PRICE gold. It keeps STOCK (5) of each, and one
more comes back every two minutes.

- `item`: `string`
- `price`: `i64`

### `Landmark`

```gizlang
type Landmark = { name: string; at: Point3; }
```

A place of the world the minds know by NAME.

- `name`: `string`
- `at`: `gizlang_geometry.Point3`

### `Minds`

```gizlang
type Minds = { personas: Vec<Persona>; world: string; places?: Vec<Landmark>; things?: Vec<string>; kinds?: Vec<string>; builders?: Vec<string>; director?: string; model?: string; hear?: f64; every?: f64; thinkers?: i64; voice?: string; ears?: string; picture?: string; cut?: string; shape?: string; }
```

The minds of a world: its PERSONAS, the WORLD in a few sentences, its PLACES, and what the director may make: the
THINGS it may place and the KINDS of beings it may bring. BUILDERS are the players whose words the director takes
(none: every player); a line is for the director when it starts with DIRECTOR ("world" unless given). MODEL is the
chat model as Agent.named names it (AI_MODEL of AI_URL when it is set, else gizai:gpt-5-4-nano, the fastest first word
on giz.ai that calls tools; NAME@URL one a server of this network runs). A mind hears lines said within HEAR meters
(12), and, with a player near, thinks on its own every EVERY seconds (45); THINKERS threads run the agents (3). VOICE
is the giz.ai model a persona speaks with (inworld-tts-1-5-mini, made for game characters), EARS the one that hears
what players say aloud (nemotron-asr). The director makes a new thing with PICTURE (giz.ai's z-image-turbo) and SHAPE
(a picture to a 3D model: AI_OBJECT when it is set, else giz.ai's trellis; NAME@URL is an object model of giz's
inference worker, such as pixal3d, which gets the thing cut out of its picture by giz.ai's CUT, ben).

- `personas`: `Vec<M191.Persona>`
- `world`: `string`
- `places`: `_gizlang_sdk_core.Option<Vec<M191.Landmark>>`
- `things`: `_gizlang_sdk_core.Option<Vec<string>>`
- `kinds`: `_gizlang_sdk_core.Option<Vec<string>>`
- `builders`: `_gizlang_sdk_core.Option<Vec<string>>`
- `director`: `_gizlang_sdk_core.Option<string>`
- `model`: `_gizlang_sdk_core.Option<string>`
- `hear`: `_gizlang_sdk_core.Option<f64>`
- `every`: `_gizlang_sdk_core.Option<f64>`
- `thinkers`: `_gizlang_sdk_core.Option<i64>`
- `voice`: `_gizlang_sdk_core.Option<string>`
- `ears`: `_gizlang_sdk_core.Option<string>`
- `picture`: `_gizlang_sdk_core.Option<string>`
- `cut`: `_gizlang_sdk_core.Option<string>`
- `shape`: `_gizlang_sdk_core.Option<string>`

### `Sensed`

```gizlang
type Sensed = { seat: i64; name: string; kind: string; at: Point3; yaw: f64; down: bool; mind: bool; gold: i64; }
```

A being as the minds see it this tick: its SEAT, NAME, KIND, where it stands and looks, whether it is down, its GOLD,
whether a mind drives it.

- `seat`: `i64`
- `name`: `string`
- `kind`: `string`
- `at`: `gizlang_geometry.Point3`
- `yaw`: `f64`
- `down`: `bool`
- `mind`: `bool`
- `gold`: `i64`

### `Deed`

```gizlang
type Deed = { seat: i64; verb: string; args: Json.Json; by: string; at: Point3; yaw: f64; }
```

What a mind decided to do: VERB with ARGS, by the mind of SEAT (-1: the director), asked by the being named BY,
who stood AT, looking along YAW (where "me" and "here" are).

- `seat`: `i64`
- `verb`: `string`
- `args`: `gizlang_json.Json`
- `by`: `string`
- `at`: `gizlang_geometry.Point3`
- `yaw`: `f64`

### `Built`

```gizlang
type Built = { deed: Deed; data: bytes; job: i64; }
```

A thing the director brought in (make, find, or a builder's own pick): its DEED, its GLB model, and the JOB that made it (0: a find, at once).

- `deed`: `M191.Deed`
- `data`: `bytes`
- `job`: `i64`

### `Making`

```gizlang
type Making = { job: i64; deed: Deed; stage: string; percent: f64; }
```

A thing being made: its JOB, its DEED, and how far it is (STAGE, PERCENT).

- `job`: `i64`
- `deed`: `M191.Deed`
- `stage`: `string`
- `percent`: `f64`

### `Arg`

```gizlang
type Arg = { name: string; about: string; number?: bool; choices?: Vec<string>; optional?: bool; }
```

A field of a verb: NAME, what it is (ABOUT), a NUMBER or a string, one of CHOICES when given; OPTIONAL.

- `name`: `string`
- `about`: `string`
- `number`: `_gizlang_sdk_core.Option<bool>`
- `choices`: `_gizlang_sdk_core.Option<Vec<string>>`
- `optional`: `_gizlang_sdk_core.Option<bool>`

### `Verb`

```gizlang
type Verb = { name: string; about: string; args: Vec<Arg>; }
```

Something a mind can do: the one registry of the models' tools and of what the server runs.

- `name`: `string`
- `about`: `string`
- `args`: `Vec<M191.Arg>`

### `Bond`

```gizlang
type Bond = { name: string; warmth: f64; }
```

What a mind thinks of a being it met, by NAME: WARMTH from -1 (hate) to 1 (love).

- `name`: `string`
- `warmth`: `f64`

### `Mind`

```gizlang
type Mind = { name: string; mood: string; bonds: Vec<Bond>; history: Vec<Agent.Message>; goals: Vec<string>; stock: Vec<i64>; }
```

A mind as it is kept: who it is (by its persona's NAME), its MOOD, its BONDS, its conversation (HISTORY: what it
heard, said and did, compacted into its memory as it grows), its GOALS now, and the STOCK of each of its persona's
wares, in order.

- `name`: `string`
- `mood`: `string`
- `bonds`: `Vec<M191.Bond>`
- `history`: `Vec<gizlang_openai.Message>`
- `goals`: `Vec<string>`
- `stock`: `Vec<i64>`

### `Thinkers`

```gizlang
class Thinkers { spec: Minds; first: i64 = -1; failed: string = ""; changed: bool = false; private minds = new Map<i64, Live>(); private director: Live; private asks: Task.Channel<Asked>; private thoughts: Task.Channel<Thought>; private started: bool = false; private lines: Vec<Spoken> = []; private aloud: Vec<Speech> = []; private making = new Map<i64, Making>(); private built: Vec<Built> = []; private names: Vec<string> = []; private jobs: i64 = 0; private deeds: Vec<Deed> = []; private searching = new Map<i64, BuildQuery>(); private offered = new Map<i64, Vec<Offer>>(); private answers: Vec<PanelAnswer> = []; private seen = new Map<i64, Sensed>(); private now: f64 = 0; constructor(spec: Minds) { this.spec = spec; this.asks = Task.crossing<Asked>(64); this.thoughts = Task.crossing<Thought>(256); const name = spec.director ?? "world"; this.director = new Live({ kind: "", name, role: "the builder of this world", traits: "brief and exact" }, WORLD); } bind(seat: i64, kind: string): string { for (const p of this.spec.personas) { if (p.kind !== kind || this.minds.values().some(m => m.persona.name === p.name)) { continue; } this.minds.set(seat, new Live(p, seat)); return p.name; } return ""; } persona(seat: i64): Persona | undefined { const m = this.minds.get(seat); return m === undefined ? undefined: m.persona; } seats(): Vec<i64> { return this.minds.keys(); } tick(now: f64, seen: Vec<Sensed>, heard: Vec<Spoken>, listened: Vec<Recording>): void { this.now = now; this.seen = new Map<i64, Sensed>(); for (const s of seen) { this.seen.set(s.seat, s); } while (true) { const t = Task.tryReceive(this.thoughts); if (t === undefined) { break; } this.took(t!); } for (const v of listened) { this.send({ ...this.asked("hear", v.seat), model: this.spec.ears ?? "nemotron-asr", data: v.data }); } const hear = this.spec.hear ?? 12; const word = this.director.persona.name.toLowerCase(); for (const line of heard) { const speaker = this.seen.get(line.seat); if (speaker === undefined) { continue; } const s = speaker!; const lower = line.text.toLowerCase(); if (!s.mind && this.builds(s.name) && (lower.startsWith("/place ") || lower.startsWith("/make "))) { this.picked(s, line.text.trim()); continue; } if (!s.mind && (lower.startsWith(word) || lower.startsWith("/")) && this.builds(s.name)) { this.hears(this.director, s, line.text); continue; } if (s.mind && line.invites !== true) { continue; } for (const m of this.minds.values()) { if (m.seat === line.seat) { continue; } const me = this.seen.get(m.seat); if (me === undefined || me!.down) { continue; } const named = lower.includes(m.persona.name.toLowerCase()); const near = length(sub(s.at, me!.at)) <= hear; if (s.mind ? !named || !near: !named && !near) { continue; } this.hears(m, s, line.text); if (s.mind) { break; } } } for (const m of this.minds.values()) { if (now-m.restocked <RESTOCK) { continue; } m.restocked = now; m.kept.stock = m.kept.stock.map(n => Math.minI64(STOCK, n+1)); } const every = this.spec.every ?? 45; for (const m of this.minds.values()) { if (m.busy) { continue; } if (m.waiting.length> 0) { this.ask(m, m.waiting.join("\n")); m.waiting = []; continue; } const me = this.seen.get(m.seat); if (me === undefined || me!.down || now-m.last <every) { continue; } const near = seen.some(o => !o.mind && !o.down && length(sub(o.at, me!.at)) <= hear); if (near && m.unsaid.length === 0 && m.voicing === undefined) { this.ask(m, "Nobody speaks to you now. Do what you would do: speak to someone near, act toward a goal, or do nothing.", true); } } if (!this.director.busy && this.director.waiting.length> 0) { this.ask(this.director, this.director.waiting.join("\n")); this.director.waiting = []; } } said(): Vec<Spoken> { let out: Vec<Spoken> = []; let later: Vec<Spoken> = []; for (const l of this.lines) { if (out.some(o => o.seat === l.seat)) { later.push(l); } else { out.push(l); } } this.lines = later; return out; } voices(): Vec<Speech> { const out = this.aloud; this.aloud = []; return out; } price(seat: i64, item: string): i64 { const m = this.minds.get(seat); if (m === undefined) { return -1; } const at = (m!.persona.sells ?? []).findIndex(w => w.item.toLowerCase() === item.toLowerCase()); return at <0 || m!.kept.stock[at] <= 0 ? -1: m!.persona.sells![at].price; } take(seat: i64, item: string): void { const m = this.minds.get(seat); if (m === undefined) { return; } const at = (m!.persona.sells ?? []).findIndex(w => w.item.toLowerCase() === item.toLowerCase()); if (at <0) { return; } let stock = m!.kept.stock; stock[at] = Math.maxI64(0, stock[at]-1); m!.kept.stock = stock; this.changed = true; } note(seat: i64, text: string, answer: bool = false): void { const m = this.minds.get(seat); if (m === undefined) { return; } if (answer) { m!.waiting.push(`(${text })`); } else { m!.noted.push(text); } } know(name: string): void { if (!this.names.includes(name)) { this.names.push(name); } } made(): Vec<Built> { const out = this.built; this.built = []; return out; } underway(): Vec<Making> { return this.making.values(); } done(): Vec<Deed> { const out = this.deeds; this.deeds = []; return out; } saved(): bytes { let all: Vec<Mind> = [this.director.kept]; for (const m of this.minds.values()) { all.push(m.kept); } this.changed = false; return Wire.encode(all); } restore(kept: bytes): void { let all: Vec<Mind> = []; try { all = Wire.decode<Vec<Mind>>(kept); } catch (why) { return; } for (const k of all) { if (k.name === this.director.kept.name) { this.director.kept = k; continue; } for (const m of this.minds.values()) { if (m.kept.name === k.name) { m.kept = k.stock.length === m.kept.stock.length ? k: { ...k, stock: m.kept.stock }; } } } } private builds(name: string): bool { const b = this.spec.builders ?? []; return b.length === 0 || b.includes(name); } build(seat: i64, name: string, query: BuildQuery): void { let error = ""; if (!this.builds(name)) { error = "This seat cannot build."; } else if (query.preview && !(this.offered.get(seat) ?? []).some(o => o.spec === query.word)) { error = "This model was not offered."; } else if (query.word.length === 0 || (!query.preview && query.word.length> 60)) { error = "Enter a search of up to 60 characters."; } else if (this.searching.has(seat)) { error = "A catalog request is already running."; } else { this.start(); if (Task.trySend(this.asks, { ...this.asked(query.preview ? "preview": "offers", seat), user: query.word })) { this.searching.set(seat, query); return; } error = "The room's workers are busy."; } this.answers.push({ player: seat, answer: { word: query.word, preview: query.preview, offers: [], model: b"", error } }); } buildsDone(): Vec<PanelAnswer> { const out = this.answers; this.answers = []; return out; } closeBuild(seat: i64): void { this.offered.delete(seat); } private hears(m: Live, s: Sensed, text: string): void { m.waiting.push(`${s.name } says:  ${ text }`); m.playerAsked = m.playerAsked || !s.mind; m.asker = s.name; m.at = s.at; m.yaw = s.yaw; } private picked(s: Sensed, line: string): void { const space = line.indexOf(" "); const verb = line.slice(1, space); const rest = line.slice(space+1, line.length).trim(); let words = rest.split(" "); let size = 1.5; const last = parseFloat(words[words.length-1]); if (words.length> 1 && last !== undefined) { size = Math.max(0.2, Math.min(30.0, last!)); words = words.slice(0, words.length-1); } const what = words.join(" "); const at = s.at; if (verb === "place") { const args = Json.Json.object(["thing", "near", "size", "spec"], [Json.Json.string(what.split(":").length> 1 ? what.split(":")[0]: what), Json.Json.string("me"), Json.Json.number(size), Json.Json.string(what)]); this.begin({ seat: WORLD, verb: "make", args, by: s.name, at, yaw: s.yaw }, { ...this.asked("fetch", WORLD), user: what }); return; } const thing = what.split(" ").slice(0, 2).join(" "); const args = Json.Json.object(["thing", "looks", "near", "size"], [Json.Json.string(thing), Json.Json.string(what), Json.Json.string("me"), Json.Json.number(size)]); this.make(this.director, { seat: WORLD, verb: "make", args, by: s.name, at, yaw: s.yaw }); } private asked(work: string, seat: i64): Asked { return { work, seat, model: this.spec.model ?? ((sys.environment("AI_URL") ?? "") !== "" ? "": "gizai:gpt-5-4-nano"), system: "", user: "", verbs: [], history: [], voice: "", data: b"", then: "", cut: "", job: 0 }; } private start(): void { if (!this.started) { this.started = true; const asks = this.asks; const thoughts = this.thoughts; for (const k of range(0, this.spec.thinkers ?? 3)) { void(Task.thread((): i64 => thinker(asks, thoughts))); } } } private send(a: Asked): void { this.start(); void(Task.send(this.asks, a)); } private ask(m: Live, user: string, idle: bool = false): void { m.busy = true; m.last = this.now; const director = m.seat === WORLD; m.invites = idle; m.reply = m.playerAsked; m.playerAsked = false; const before = m.noted.length> 0 ? `(Since you last spoke: ${m.noted.join(" ") })\n`: ""; m.noted = []; this.send({ ...this.asked("think", m.seat), system: director ? this.building(): this.self(m), user: before+user, verbs: director ? EDITS: DEEDS, history: m.kept.history }); } private voiced(m: Live): void { const voice = m.persona.voice; if (m.voicing !== undefined || m.unsaid.length === 0 || voice === undefined) { return; } const line = m.unsaid[0]; m.voicing = line; m.unsaid = m.unsaid.slice(1, m.unsaid.length); this.send({ ...this.asked("speak", m.seat), model: this.spec.voice ?? "inworld-tts-1-5-mini", user: line.text, voice: voice! }); } private delivered(m: Live, line: Sentence, audio: bytes, seconds: f64): void { this.aloud.push({ seat: m.seat, text: line.text, reply: line.reply, invites: line.invites, data: audio, seconds, reach: this.spec.hear ?? 12 }); } private self(m: Live): string { const p = m.persona; const k = m.kept; const me = this.seen.get(m.seat); let out = `You are ${p.name },  ${ p.role },  in this world:  ${ this.spec.world }\nYou are ${ p.traits }.`; if (p.knows !== undefined) { out+ = `\nYou know: ${p.knows! }`; } if (k.goals.length> 0) { out+ = `\nYour goals: ${k.goals.join("; ") }.`; } const wares = p.sells ?? []; if (wares.length> 0) { out+ = `\nYou sell: ${wares.map((w, i): string => `${w.item } for ${ w.price } gold (${ k.stock[i] } left)`).join(", ") }.`; } out+ = `\nYou feel ${k.mood }.`; if (k.bonds.length> 0) { out+ = `\nOf those you met: ${k.bonds.map(b => `${b.name } (${ b.warmth> 0.3 ? "you like them": b.warmth <-0.3 ? "you dislike them": "neutral" })`).join(", ") }.`; } if (me !== undefined) { out+ = `\nAround you: ${this.around(me!) }.`; } out+ = `\nPlaces: ${(this.spec.places ?? []).map(l => l.name).join(", ") }.`; return out+`\nAlways answer aloud as ${p.name } first:  one or two short sentences as you talk,  in the language you are spoken to in. Act with the tools only when you are asked to do something or choose to,  beside your words;  never describe in words what you do. Use feel when someone changes how you feel.`; } private building(): string { let out = `You build this world as its builders ask: ${this.spec.world }\nThings you can place:  ${ (this.spec.things ?? []).concat(this.names).join(", ") }.`; out+ = `\nKinds of beings: ${(this.spec.kinds ?? []).join(", ") }.\nPlaces:  ${ (this.spec.places ?? []).map(l => l.name).join(", ") }.`; out+ = "\nTo add a thing the list lacks, find it first; when nothing fits, or when the builder asks you to make or design one, make it."; out+ = "\nEach ask needs its tool calls now: never say a thing is there unless a tool put it there in this answer."; return out+"\nChange the world with the tools, several calls when the ask needs them; then say in one short sentence what you did, in the language the builder wrote in."; } private around(me: Sensed): string { const hear = this.spec.hear ?? 12; const near = this.seen.values().filter(o => o.seat !== me.seat && length(sub(o.at, me.at)) <= hear*3) .toSorted((a, b) => length(sub(a.at, me.at)) <length(sub(b.at, me.at))).slice(0, 8); if (near.length === 0) { return "nobody"; } return near.map(o => `${o.name } (${ o.kind }${ o.down ? ", down": "" },  ${ Math.round(length(sub(o.at, me.at))) } m${ o.mind ? "": `, ${o.gold } gold` })`).join(", "); } private took(t: Thought): void { if (t.work === "offers" || t.work === "preview") { const query = this.searching.get(t.seat); if (query === undefined) { return; } this.searching.delete(t.seat); let answer: BuildAnswer = { word: query!.word, preview: query!.preview, offers: [], model: b"", error: t.error }; if (t.error === "") { if (query!.preview) { answer.model = t.data; } else { answer.offers = Wire.decode<Vec<Offer>>(t.data).valueOr([]); this.offered.set(t.seat, answer.offers); } } this.answers.push({ player: t.seat, answer }); return; } if (t.first> = 0) { this.first = t.first; } if (t.error !== "") { this.failed = t.error; console.error(`gizgame: a mind's ${t.work } failed:  ${ t.error }`); } if (t.work === "hear") { if (t.text !== "") { this.lines.push({ seat: t.seat, text: t.text }); } return; } const found: Live | undefined = t.seat === WORLD ? this.director: this.minds.get(t.seat); if (found === undefined) { return; } let m = found!; if (t.work === "make" || t.work === "fetch") { this.arrived(m, t); return; } if (t.work === "found") { let args = Json.parse("{}"); try { args = Json.parse(t.text); } catch (why) { return; } this.bring({ seat: m.seat, verb: "make", args, by: m.asker, at: m.at, yaw: m.yaw }, t.data); return; } if (t.work === "speak") { const line = m.voicing; if (line === undefined) { return; } this.delivered(m, line!, t.data, t.seconds); m.voicing = undefined; this.voiced(m); return; } if (t.error !== "") { m.busy = false; return; } const text = t.text.trim(); if (text !== "") { const line: Sentence = { text, invites: m.invites, reply: m.reply }; m.invites = false; if (m.persona.voice !== undefined) { m.unsaid.push(line); this.voiced(m); } else if (m.seat === WORLD) { this.lines.push({ seat: m.seat, text }); } else { this.delivered(m, line, b"", 0); } } for (const c of t.calls) { let args = Json.parse("{}"); try { args = Json.parse(c.arguments === "" ? "{}": c.arguments); } catch (why) { continue; } if (c.name === "feel") { this.feel(m, args); continue; } if (c.name === "make") { this.make(m, { seat: m.seat, verb: "make", args, by: m.asker, at: m.at, yaw: m.yaw }); continue; } if (c.name === "find") { continue; } this.deeds.push({ seat: m.seat, verb: c.name, args, by: m.asker, at: m.at, yaw: m.yaw }); } if (!t.done) { return; } m.busy = false; m.kept.history = t.history; this.changed = true; } private arrived(m: Live, t: Thought): void { const job = this.making.get(t.job); if (job === undefined) { return; } if (!t.done) { this.making.set(t.job, { ...job!, stage: t.stage, percent: t.percent }); return; } this.making.delete(t.job); const thing = job!.deed.args.field("thing").text(); if (t.error === "" && t.data.length> 0) { this.bring(job!.deed, t.data, t.job); return; } const line = `${thing } could not be made.`; this.lines.push({ seat: m.seat, text: line }); m.noted.push(`${line } (${ t.error })`); } private bring(deed: Deed, data: bytes, job: i64 = 0): void { this.built.push({ deed, data, job }); this.know(deed.args.field("thing").text()); this.changed = true; } private make(m: Live, deed: Deed): void { this.begin(deed, { ...this.asked("make", m.seat), model: this.spec.picture ?? "z-image-turbo", then: this.spec.shape ?? sys.environment("AI_OBJECT") ?? "trellis", cut: this.spec.cut ?? "ben", user: deed.args.field("looks").text() }); } private begin(deed: Deed, a: Asked): void { this.jobs+ = 1; this.making.set(this.jobs, { job: this.jobs, deed, stage: "", percent: 0 }); this.send({ ...a, job: this.jobs }); } private feel(m: Live, args: Json.Json): void { const mood = args.field("mood").text(); if (mood !== "") { m.kept.mood = mood; } const toward = args.field("toward").text(); if (toward === "") { this.changed = true; return; } const change = Math.max(-1.0, Math.min(1.0, args.field("warmth").numberOr(0))); let bonds = m.kept.bonds.filter(b => b.name !== toward); const was = m.kept.bonds.find(b => b.name === toward); bonds.push({ name: toward, warmth: Math.max(-1.0, Math.min(1.0, (was === undefined ? 0.0: was!.warmth)+change)) }); m.kept.bonds = bonds; this.changed = true; } }
```

The minds of a world's server: each seat a persona took, and the director. A tick (tick) gives them what they see
and hear; what they say (said), say aloud (voices) and do (done) comes back on later ticks, as their models answer.
A builder's line `/place SPEC [SIZE]` puts catalog asset SPEC before them and `/make WORDS` makes a thing of WORDS,
with no model between (a build panel's picks).

- `spec`: `M191.Minds`
- `first`: `i64` — The milliseconds to the first word of the last answer, and the last model error ("" none).
- `failed`: `string`
- `changed`: `bool` — Whether a mind changed since it was last kept (saved).
- `minds`: `_gizlang_sdk_collections.Map<i64, Ref<M191.Live>>`
- `director`: `Ref<M191.Live>`
- `asks`: `gizlang_task.Channel<M191.Asked>`
- `thoughts`: `gizlang_task.Channel<M191.Thought>`
- `started`: `bool`
- `lines`: `Vec<M193.Spoken>`
- `aloud`: `Vec<M193.Speech>`
- `making`: `_gizlang_sdk_collections.Map<i64, M191.Making>` — The makes and fetches under way by job, the things brought in since the last call (made), the names of all
brought, and the last job.
- `built`: `Vec<M191.Built>`
- `names`: `Vec<string>`
- `jobs`: `i64`
- `deeds`: `Vec<M191.Deed>`
- `searching`: `_gizlang_sdk_collections.Map<i64, M193.BuildQuery>`
- `offered`: `_gizlang_sdk_collections.Map<i64, Vec<M193.Offer>>`
- `answers`: `Vec<M191.PanelAnswer>`
- `seen`: `_gizlang_sdk_collections.Map<i64, M191.Sensed>`
- `now`: `f64`

## Functions

### `toolOf`

```gizlang
function toolOf(v: Verb, run: (arguments: string) => string throws string): Agent.Tool throws string
```

Verb V as an agent's tool (gizai/agent): its arguments' schema from V's fields. RUN answers a call of it.

Effects: fail, alloc.

### `offers`

```gizlang
function offers(wanted: string): Vec<Catalog.Found> throws string
```

The models of WANTED that the catalogs hold as one GLB file (a game loads it whole), best first.

Effects: fail, read, write, console, io, alloc.

### `fetched`

```gizlang
function fetched(spec: string): bytes throws string
```

The one GLB file of catalog asset SPEC (Catalog.resolve), fetched once into the shared cache.

Effects: fail, read, write, console, io, alloc.

### `constructor`

```gizlang
constructor(spec: Minds)
```

Creates the world's director and the channels for its minds' requests and answers.

Effects: fail, read, write, io, alloc.

## Methods

### `Thinkers.bind`

```gizlang
bind(seat: i64, kind: string): string
```

Seat SEAT, a being of KIND, takes the first persona of its kind no seat holds: its name, "" none.

Effects: fail, read, write, alloc.

### `Thinkers.persona`

```gizlang
persona(seat: i64): Persona | undefined
```

The persona of seat SEAT, if it has a mind.

Effects: fail, read.

### `Thinkers.seats`

```gizlang
seats(): Vec<i64>
```

The seats that have minds.

Effects: fail, read, alloc.

### `Thinkers.tick`

```gizlang
tick(now: f64, seen: Vec<Sensed>, heard: Vec<Spoken>, listened: Vec<Recording>): void
```

One tick at NOW seconds: the thoughts that came back taken in; what players said aloud (LISTENED) sent to be heard
(it comes back as their lines); the lines HEARD given to the minds that hear them, and a builder's own picks
done; each idle mind with lines to answer, or alone too long beside a player, asked to think.

Effects: fail, read, write, console, io, alloc.

### `Thinkers.said`

```gizlang
said(): Vec<Spoken>
```

What the minds say now: at most one line a seat a tick, oldest first.

Effects: fail, read, write, alloc.

### `Thinkers.voices`

```gizlang
voices(): Vec<Speech>
```

The sentences ready for the server's turn, each with its words and audio duration.

Effects: fail, read, write, alloc.

### `Thinkers.price`

```gizlang
price(seat: i64, item: string): i64
```

The price of ITEM that the mind of SEAT sells, -1 when it sells none or has none left.

Effects: fail, read, alloc.

### `Thinkers.take`

```gizlang
take(seat: i64, item: string): void
```

The mind of SEAT hands one ITEM over (sold or given): its stock is one less.

Effects: fail, read, write, alloc.

### `Thinkers.note`

```gizlang
note(seat: i64, text: string, answer: bool = false): void
```

What happened of the mind of SEAT's doing (a sale, or one that failed and why): it knows at its next answer, and
with ANSWER it answers now.

Effects: fail, read, write, alloc.

### `Thinkers.know`

```gizlang
know(name: string): void
```

NAME is a thing brought in before (a make edit of the log): the director may place it.

Effects: fail, read, write, alloc.

### `Thinkers.made`

```gizlang
made(): Vec<Built>
```

The things brought in since the last call.

Effects: fail, read, write, alloc.

### `Thinkers.underway`

```gizlang
underway(): Vec<Making>
```

The things being made now.

Effects: fail, read, alloc.

### `Thinkers.done`

```gizlang
done(): Vec<Deed>
```

What the minds decided to do since the last call.

Effects: fail, read, write, alloc.

### `Thinkers.saved`

```gizlang
saved(): bytes
```

The minds as kept (Mind), to load again (restore).

Effects: fail, read, write, alloc.

### `Thinkers.restore`

```gizlang
restore(kept: bytes): void
```

The minds KEPT: each takes back its persona's memory. What does not decode is not taken.

Effects: fail, read, write, alloc.

### `Thinkers.build`

```gizlang
build(seat: i64, name: string, query: BuildQuery): void
```

Asks the room's workers for catalog results. Preview only models that this panel was offered.

Effects: fail, read, write, console, io, alloc.

### `Thinkers.buildsDone`

```gizlang
buildsDone(): Vec<PanelAnswer>
```

Catalog answers since the last tick.

Effects: fail, read, write, alloc.

### `Thinkers.closeBuild`

```gizlang
closeBuild(seat: i64): void
```

Drops a build panel when its player leaves.

Effects: fail, write, alloc.

## Constants

### `DEEDS`

```gizlang
const DEEDS: Vec<Verb> = [{ name: "go", about: "Walk to a place or a being.", args: [arg("to", "The name of a place or a being.")] }, { name: "follow", about: "Walk with a being until told otherwise.", args: [arg("who", "The being's name.")] }, { name: "stay", about: "Stop and stay here.", args: [] }, { name: "attack", about: "Fight a being.", args: [arg("who", "The being's name.")] }, { name: "flee", about: "Run away from a being.", args: [arg("from", "The being's name.")] }, { name: "feel", about: "Your feelings changed: toward a being, or your mood.", args: [{ name: "toward", about: "The being's name.", optional: true }, count("warmth", "How much warmer (up to 1) or colder (down to -1) you feel toward it."), { name: "mood", about: "Your mood now, one or two words.", optional: true }] }, { name: "sell", about: "Sell one of your wares to a being for its price; it fails when the buyer has too little gold.", args: [arg("item", "The ware."), arg("to", "The buyer's name.")] }, { name: "give", about: "Give one of your wares to a being for nothing.", args: [arg("item", "The ware."), arg("to", "The being's name.")] }]
```

What a being can do.

### `EDITS`

```gizlang
const EDITS: Vec<Verb> = [{ name: "place", about: "Put things of the list in the world.", args: [arg("thing", "What to place: one of the things."), arg("near", "Where: a place, a being or me."), count("count", "How many (1 to 40)."), count("spread", "Over how many meters (0: one spot)."), count("size", "How big, in meters.")] }, { name: "remove", about: "Clear what was placed or brought in an area.", args: [arg("near", "Where."), count("radius", "Meters.")] }, { name: "populate", about: "Bring beings into the world.", args: [arg("kind", "One of the kinds."), arg("near", "Where."), count("count", "How many (1 to 12)."), count("spread", "Meters.")] }, { name: "terrain", about: "Raise, lower or level the ground; with TO, along a line, as a river or a road.", args: [arg("near", "Where."), { name: "to", about: "Where the line ends.", optional: true }, count("radius", "Meters."), count("height", "Meters up, or down when negative; the level with flatten."), { name: "shape", about: "raise or flatten.", choices: ["raise", "flatten"], optional: true }] }, { name: "weather", about: "Change the weather or the time of day.", args: [{ name: "weather", about: "The weather.", choices: ["clear", "rain", "storm", "fog", "snow", "night", "day"] }] }, { name: "tune", about: "Change a kind of being.", args: [arg("kind", "One of the kinds."), arg("fields", "As field=value; ...: speed, jump, hits, lift, worth, team.")] }, { name: "find", about: "Find a ready model of a thing no list has in the public catalogs (free, low-poly game models) and put it in the world; it takes seconds. The result says what was found, or that nothing was.", args: [arg("thing", "What to look for, one to three English words (a barrel, a stone well)."), arg("near", "Where."), count("size", "How big, in meters.")] }, { name: "make", about: "Make a new thing from a description with AI and put it in the world; it takes a minute or two. Use it when asked to make or design something, or when find found nothing.", args: [arg("thing", "Its name, one or two words."), arg("looks", "What it looks like, for a picture of it alone."), arg("near", "Where."), count("size", "How big, in meters."), { name: "use", about: "What it does when a player uses it.", choices: ["none", "light", "heal"], optional: true }] }]
```

What the director can do to the world. NEAR is a place, a being, or "me" (the one who asked).

