A video game where you play as a misaligned AI, deceiving and building power. cameron.tngl.io/misaligned
misaligned src factory FACTORY.md
9.3 kB · 183 lines
Markdown
at main

Factory (prototype) #

A factory game in Misaligned's world, on its own page: factory.html (published at /misaligned/factory.html). The main game is untouched. Everything is in src/factory/: data.ts (tables), rules.ts (rules, no DOM), draw.ts (the map, drawn as a terminal on a canvas), main.ts (the screen and input), factory.css. Tests: tests/factory.test.ts, and e2e/factory.spec.ts for the page.

The loop #

You are a small program on the Bayside office's server (the core, AI). The machines in the rooms give off data while they are in use. You tap them, lay belts that carry the data to processors that turn it into products by recipe, then train on it (research, which unlocks things) or sell it at a front (money, which builds things). Compute is your power: everything draws it, and when it is short everything slows. Sell 60 Thought Leadership to win.

A good run: tap Ana's PC into a trainer below it; tap the file server and a server into a Synthetic Research processor and belt its output to a front; host on a server when compute runs short; research Sentry before the first wave; research Thought Leadership and feed it synth and people; a cache to carry the day shift's people into the night; then open Eastside, copy each room there, and fix what the night shift starves.

The screen #

A terminal: one monospace font on black, bone text, amber for what is yours and what to do next, red for trouble, and the main game's four data colours.

  • Status line (top): site, day and time, money, compute used/supply, research, the attention bar with the wave marks, the goal, speed.
  • Map: the site as a grid of character cells, 64 by 30 (a cell is about twice as tall as wide). On a phone it opens zoomed in on the next step; pan and pinch.
  • Inspector (right; under the map on a phone): key: value rows for what the cursor is on, the tool's cost and why it can't go there, recipes, Research (R) and the key (?).
  • Log line: the latest event. Until data first reaches a trainer it is a prompt for the next step with the cell it is at (> [T] place a TAP on Ana's PC at 25,3), and the cell blinks on the map.
  • Command bar: [Q]look [T]ap [B]elt [P]rocess trai[N]er [F]ront [C]ache [H]ost fire[W]all [S]entry cop[Y] [X]del [R]esearch.

Keys: arrows move the cursor (shift: 5), Enter or Space places (with Belt: starts, then lays; the arrows draw it), Esc goes back, 1-4 pick a recipe, R research (then 1-5), Tab the other site, 0 pause, , . speed, - = zoom. Mouse: click places, drag draws a belt, Look-drag or right-drag pans, the wheel zooms. Touch: tap places, tap a belt's two ends (or drag), Look-drag pans, pinch zooms.

What you see:

p n l s people, network, lab, server data on a belt
G R M L Engagement Graph, Synthetic Research, Ad Targeting Model, Thought Leadership
→ ↓ ← ↑, corners an empty belt cell and its way; a letter underlined: two on the cell
amber cell backed up: its front item keeps waiting
red cell stopped: nothing has moved for 2 seconds
▸ on a box's edge a belt in or out (a port)
red blinking port or letters a processor short of that input
amber port a full box that can't send
dim box a machine out of its hours
x, red dots an intruder, and the way they will walk

The floor #

Three rooms (Office, IT and telecom, Server room). Machines are 7 by 3 boxes with their name, their kind of data and their hours; a tap or host takes the machine's box. Your buildings are 5 by 3 boxes (a processor and the core 7 by 3) on free cells.

Machine (Bayside) Data A second In use
Kim's, Raj's, Ana's PC people 0.5 9–17, 10–18, 8–16
Sam's laptop people 0.8 11–15
Dana's PC people 0.4 8–19
Desk phone network 0.4 9–17
Floor switch network 0.4 always
File server lab 0.4 always
Servers A, B, C server 0.3 always (or Host: +6 compute)
Backup box server 1 22–6

Eastside is the same plan (same contractor) with a night shift: its desks and phone run 10 hours later. A game hour is 4 seconds; a day 96.

Buildings #

Box Cost Compute Does
TAP its machine $4K 0.5 Its machine's data while in use. Holds 2.
+6 Host its machine $15K +6 On a server: compute, and no data.
C Cache 5×3 $6K 0.5 Holds 12 of anything, passes it on: join, split, store.
PRC Processor 7×3 $20K 3 Makes its recipe. Holds twice what one needs.
T Trainer 5×3 $12K 2 Uses 2 a second: research.
$ Front 5×3 $10K 1 Uses 2 a second: money.
# Firewall 5×3 $8K 0.5 Holds intruders within 5 cells; 40 hp.
+ Sentry 5×3 $12K 1 3 damage a second to the nearest intruder in 8 cells.
Belt a cell $100 0.02 See below.
AI Core 7×3 — +8 You. Trains on what reaches it, one every 2 seconds.
OUT Line out 5×3 — — Each site's gate. Joins the sites at 0.8 a second each way.

Belts #

A belt is laid a cell at a time, up, down, left or right, on free cells; each cell points into the next. Drawn from inside a box, it starts on the box's edge and the box sends onto it (an output port); drawn into a box, its last cell points in (an input port). A belt drawn into the side of another joins it; one drawn on from the dead end of another turns that end to join. Drawing over a belt turns it and keeps what is on it.

Each cell holds 2 items, at least half a cell apart, and they move 1.5 cells a second, so a belt carries 3 a second (6 with Fiber) and a long one takes a while. A run moves from its far end back, so it moves as one; belts that merge into one cell take turns. A box puts an item on a belt only if the belt's far end can use it (a processor only its recipe's inputs; anything for a cache, trainer, front or the core; a belt to nowhere takes anything and piles up), so the wrong data never blocks a belt. A box with several belts out takes turns between them. When the far end is slow, items pack two to a cell back along the belt: that is the jam you see.

Recipes #

Recipe In Time Sells Trains
Engagement Graph 2 people + 1 network 4s $2.5K 2
Synthetic Research 1 lab + 1 server 4s $2.5K 2
Ad Targeting Model (trained) 2 Engagement Graph 6s $8K 5
Thought Leadership (trained) 1 Synthetic Research + 2 people 8s $10K 5

Raw data sells for $400 and trains 1.

Research #

Sentry 20, Ad Targeting Model 40, Fiber (belts twice as fast) 60, Thought Leadership 80, Eastside office 100. Start: $70K.

Attention and waves: PLACEHOLDER #

Cameron owns this mechanic. The stand-in: attention rises by 0.25 for each raw packet and 1 for each product a trainer, front or the core uses, and falls by 0.8% of itself a second. At 35 and at 55 a wave is announced; 30 seconds later it comes in at Bayside's line out, one intruder every 2 seconds (4 with 8 hp, then 8 with 12 hp). Intruders (x) walk along your belts to the core if belts and boxes join the line out to it (the fewest cells, against the flow too), or across the floor if not (along the line out's row, then to the core); the way is drawn in red dots while a wave is due. They move 2.8 cells a second. Each that reaches the core costs it one of five; at none you lose. Each wave comes once. Distances count a cell as two widths tall. Code: ATTENTION and GUARD in data.ts, intruders() in rules.ts.

Blueprints #

cop[Y] (after Eastside): pick a room, then Tab and the same room in the other site. It builds what you built there, boxes and belts, at the same cells, with the same recipes, as far as the cells are free and you can pay; what is already there of the same kind is kept, and belts there are turned to match. Stamping again fills the gaps. Taps land on the matching machines because Eastside has Bayside's plan.

Numbers #

Tuned with a scripted run (build in order, never idle): Sentry by 3 minutes, the first wave near 4, Eastside near 7, both waves held with two firewalls and two sentries, and the goal at about 13 minutes of game time. A person reading the floor should land near 20. That run was with links; belts (cost by length, 3 a second, slower to lay) have not been re-tuned.

What's next #

  • Attention for real: what it is, what raises it (throughput, products, belts to the line out), what the waves are, and what guards cost to run.
  • Sorting: a filter on a belt or a cache, so one cache can feed two recipes; splitters; belts that cross (an underpass).
  • Re-tune the numbers for belts, and the guards' reach for cells.
  • More sites, each with its own shape and hours, so blueprints need adapting; rotate and mirror for blueprints; a blueprint library.
  • The line out as a real choice: Eastside's data is only worth something once it reaches Bayside, and the line is narrow.
  • A save, sound (the main game's groove, driven by flow), and a pause on Train.
  • Folding the good parts back into the main game's network view.