{
  "version": "https://jsonfeed.org/version/1.1",
  "title": "devlog",
  "description": "The captain's engineering log.",
  "home_page_url": "https://alchemy86.github.io/devlog/",
  "feed_url": "https://alchemy86.github.io/devlog/feed.json",
  "language": "en-GB",
  "items": [
    {
      "id": "https://alchemy86.github.io/devlog/posts/a-liquid-turn.html",
      "url": "https://alchemy86.github.io/devlog/posts/a-liquid-turn.html",
      "title": "A liquid turn",
      "summary": "A maths Pokémon only has three real drawings: front, side and back. Turning between them used to cut. Now the outline pours from one silhouette into the next, and every angle in between is worked out live from those three drawings.",
      "content_html": "<figure style=\"margin-inline:auto;\">\n  <video controls=\"\" playsinline=\"\" preload=\"metadata\" poster=\"../assets/img/pokewalker/liquid-nidoking-thermal-poster.jpeg\" width=\"1280\" height=\"360\">\n    <source src=\"../assets/video/pokewalker/liquid-nidoking-thermal.mp4\" type=\"video/mp4\" />\n  </video>\n  <figcaption>Nidoking bracing while the camera circles him, in heat colours. Left: the old seam. Right: the liquid turn.</figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <p>The creatures on the walker <a href=\"./a-pokemon-made-of-maths.html\">are made of maths</a>, and lately\nthey <a href=\"./moves-are-numbers-too.html\">move like it too</a>. But each one only has a few real\nviews: a front, a side and a back. The other side is the first one mirrored. That is all an\nartist ever drew for a follower, and it is all we have.</p>\n\n  <p>So when the camera swung round a creature, it cut from one view to the next. Nidoking would\nbe side on, and then, one degree later, he would be facing you. A little blip, every quarter\nturn. It's fine on a sprite that never moves the camera. It looks awful in a park you can\nwalk round.</p>\n\n  <h2>First try: move the parts</h2>\n\n  <p>The creature is already built from parts: a head, a body, arms, a tail. So the obvious idea\nwas to turn each part on its own, slide it round the body, and let them overlap properly.</p>\n\n</section>\n\n<figure style=\"margin-inline:auto;\">\n  <video controls=\"\" playsinline=\"\" preload=\"metadata\" poster=\"../assets/img/pokewalker/liquid-charizard-parts-poster.jpeg\" width=\"1280\" height=\"720\">\n    <source src=\"../assets/video/pokewalker/liquid-charizard-parts.mp4\" type=\"video/mp4\" />\n  </video>\n  <figcaption>Left: parts turned one by one. Right: the relief, the second try.</figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <p>It pulled his face off. The parts were cut out of a flat drawing, so they have no idea how\ndeep they are. Turn them and the snout drifts away from the head, and the head drifts away\nfrom the neck. Watch the left-hand Charizard for a bit and it gets quite upsetting.</p>\n\n  <h2>Second try: a relief</h2>\n\n  <p>So stop thinking in parts and think in bodies. Take each view and lift it into a shallow\nrelief, row by row: as wide as this view's ink, and as deep as the neighbouring view's ink.\nThe side view tells you how deep the front is, and the front tells you how deep the side is.\nTurn that with a depth buffer and you get one solid body, not a pile of stickers.</p>\n\n  <p>That was much better, on the right above. But each relief is still only good near its own\nview. At some point you have to hand over from the front's relief to the side's, and at the\nhandover the outline snaps. A smaller blip, but still a blip.</p>\n\n  <h2>Third try: pour it</h2>\n\n  <p>Now the turn is liquid. At any bearing, both neighbouring views are turned to face the\ncamera. Each one becomes a distance field: for every pixel, how far it is from that view's\noutline, inside or out. The outline drawn on screen is where a blend of the two fields\ncrosses zero, and the blend eases across the whole quarter turn. The shape pours from one\nsilhouette into the next, like filling a Pikachu-shaped bottle.</p>\n\n</section>\n\n<figure style=\"margin-inline:auto;\">\n  <video controls=\"\" playsinline=\"\" preload=\"metadata\" poster=\"../assets/img/pokewalker/liquid-nidoking-compare-poster.jpeg\" width=\"1280\" height=\"720\">\n    <source src=\"../assets/video/pokewalker/liquid-nidoking-compare.mp4\" type=\"video/mp4\" />\n  </video>\n  <figcaption>Nidoking orbited. Left: the seam. Right: liquid.</figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <p>Colour is the fiddly part, because a blend of two colours is a colour neither drawing has,\nand the whole point of these creatures is crisp pixel art. So each pixel looks up the\nmatching spot in both views, by how far down the row it sits, and takes one of the two real\npalette colours. Which one it takes switches over on a Bayer pattern, so the change sweeps\nacross the body as a staggered dither rather than a smear. Every pixel on screen is still a\ncolour the artist chose.</p>\n\n</section>\n\n<figure style=\"margin-inline:auto;\">\n  <video controls=\"\" playsinline=\"\" preload=\"metadata\" poster=\"../assets/img/pokewalker/liquid-charizard-compare-poster.jpeg\" width=\"720\" height=\"720\">\n    <source src=\"../assets/video/pokewalker/liquid-charizard-compare.mp4\" type=\"video/mp4\" />\n  </video>\n  <figcaption>Charizard, the same comparison.</figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <p>Nothing in between is stored. There is no diagonal drawing of Charizard anywhere. The 45°\nview, the 37° view, the 3° view are all worked out live, every frame, from those three\ndrawings.</p>\n\n</section>\n\n<figure style=\"max-width:none;margin-inline:auto;\">\n  <img src=\"../assets/img/pokewalker/liquid-eight.jpeg\" width=\"1294\" height=\"489\" alt=\"Charizard in eight directions. South, west and north are the stored drawings, east is west mirrored, and the four diagonals are worked out, each also shown approached from both sides.\" />\n  <figcaption>Eight directions. Only S, W and N were drawn. Each diagonal is shown from both neighbours, and they agree.</figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <h2>Did it work?</h2>\n\n  <p>To put a number on \"snaps\", I turn the camera one degree at a time and measure how much of\nthe picture changes each step. A smooth turn changes a bit every step. A snap is one step\nthat changes far more than the rest. So the score is the biggest step over the typical one.</p>\n\n</section>\n\n<figure style=\"max-width:none;margin-inline:auto;\">\n  <img src=\"../assets/img/pokewalker/liquid-snap.jpeg\" width=\"740\" height=\"378\" alt=\"Two bar charts of change per one-degree step for Nidoking. The seam (orange) has tall isolated spikes; liquid (blue) is busier but far flatter.\" />\n  <figcaption>Change per degree for Nidoking, all the way round. Seam on top, liquid below.</figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <table>\n    <thead>\n      <tr>\n        <th>Biggest step ÷ typical step</th>\n        <th>Seam</th>\n        <th>Liquid</th>\n      </tr>\n    </thead>\n    <tbody>\n      <tr>\n        <td>Charizard</td>\n        <td>5.4</td>\n        <td>3.1</td>\n      </tr>\n      <tr>\n        <td>Nidoking</td>\n        <td>5.8</td>\n        <td>3.1</td>\n      </tr>\n      <tr>\n        <td>Charizard in battle</td>\n        <td>4.6</td>\n        <td>2.9</td>\n      </tr>\n    </tbody>\n  </table>\n\n  <p>The spikes are gone. The honest cost is in the graph too: the blue baseline is a bit busier,\nbecause the dither is always shimmering a little somewhere while the body pours. I'll take a\ngentle shimmer over a blip every quarter turn.</p>\n\n  <p>It's all integer maths with no allocation, the same rules as the rest of the creature code,\nso it can run anywhere the walker does. Next it goes into battles, the park, flight and the\nshorts, wherever a camera gets to move round a creature.</p>\n\n</section>\n",
      "date_published": "2026-11-17T21:00:00+00:00"
    },
    {
      "id": "https://alchemy86.github.io/devlog/posts/moves-are-numbers-too.html",
      "url": "https://alchemy86.github.io/devlog/posts/moves-are-numbers-too.html",
      "title": "Moves are numbers too",
      "summary": "A maths creature's moves are curves of bone angles stored in the creature itself. Some are written by rule, some keyed by hand, some come from a motion model, and all of them survive a remake. Charizard now takes off, flaps, glides and banks in the park with them.",
      "content_html": "<figure style=\"margin-inline:auto;\">\n  <video controls=\"\" playsinline=\"\" preload=\"metadata\" poster=\"../assets/img/pokewalker/maths-motion-takeoff-poster.jpeg\" width=\"960\" height=\"540\">\n    <source src=\"../assets/video/pokewalker/maths-motion-takeoff.mp4\" type=\"video/mp4\" />\n  </video>\n  <figcaption>Charizard taking off in the park, recorded straight out of the walker's own renderer: the crouch, the leap, the climbing wingbeat, then a glide that leans into each turn.</figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <p>That is the real park flight, the same code the browser walker and the portal run. The only\nthing new in it is what Charizard knows how to do.</p>\n\n  <h2>A move is a curve, not a flipbook</h2>\n\n  <p>The creatures on the walker <a href=\"./a-pokemon-made-of-maths.html\">are made of maths</a>: outlines,\na skeleton, and moves. A sprite animation stores every frame as pixels. A move here stores\nnone. It is a set of curves, one per bone, saying how far that bone is turned at each moment,\nplus the odd nudge or squash. Those curves live inside the creature's own file, next to its\nshapes.</p>\n\n  <p>Every frame the walker asks \"where is every bone at 1,240 ms?\", poses the skeleton and draws\nthe outlines fresh at 1x, on the creature's own pixel grid. That has a few nice side effects.\nA move plays at any speed and any frame rate, because time is continuous and there are no\nframes to drop. Two moves can be faded into each other, because halfway between two angles\nis just another angle. And a move costs a few kilobytes at most, not a sprite sheet.</p>\n\n  <h2>Three ways to make one</h2>\n\n  <p><strong>By rule.</strong> Every creature gets a set of moves the moment it is made: idle, hop, attack, a\nlook round, a tail swish. They are built from the skeleton alone, so they work on anything\nwith a tail or a head. Nidoking's tail used to sit still while he idled. One command folded a\nswish into his idle, twice as big and lagging down the tail so the tip follows the base:</p>\n\n</section>\n\n<figure style=\"margin-inline:auto;\">\n  <video controls=\"\" playsinline=\"\" loop=\"\" muted=\"\" autoplay=\"\" preload=\"metadata\" poster=\"../assets/img/pokewalker/maths-motion-nidoking-idle-poster.jpeg\" width=\"736\" height=\"336\">\n    <source src=\"../assets/video/pokewalker/maths-motion-nidoking-idle.mp4\" type=\"video/mp4\" />\n  </video>\n  <figcaption>Nidoking's idle before and after <code>make swish --into idle --gain 2 --lag 14</code>. Left: before. Right: the tail sways.</figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <p><strong>By hand.</strong> Rules are good at loops. They are bad at a single moment with weight in it. For\nthose I set a handful of keys on the bones and let the easing do the rest. Nidoking's brace\nis 150 ms of snap: a little anticipation first, then the body snaps back past where it ends\nup and settles, the arms pull in, the back arches, the knees flex and the feet stay planted.\nEvery one of those is a few keys on one bone.</p>\n\n</section>\n\n<figure style=\"margin-inline:auto;\">\n  <video controls=\"\" playsinline=\"\" loop=\"\" muted=\"\" autoplay=\"\" preload=\"metadata\" poster=\"../assets/img/pokewalker/maths-motion-nidoking-brace-poster.jpeg\" width=\"720\" height=\"330\">\n    <source src=\"../assets/video/pokewalker/maths-motion-nidoking-brace.mp4\" type=\"video/mp4\" />\n  </video>\n  <figcaption>Nidoking bracing, keyed by hand.</figcaption>\n</figure>\n\n<figure style=\"max-width:none;margin-inline:auto;\">\n  <img src=\"../assets/img/pokewalker/maths-motion-nidoking-strip.jpeg\" width=\"1400\" height=\"560\" alt=\"Ten frames of the maths Nidoking bracing: standing at rest, then pulling its arms in, arching its back and flexing its knees.\" />\n  <figcaption>The brace frame by frame.</figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <p><strong>From a motion model.</strong> <a href=\"./new-moves-from-a-sentence.html\">Today's earlier post</a> was about\nKimodo, which writes a human movement from a sentence. Its sibling MotionBricks does two\nthings Kimodo can't: steer a walk towards a target, and fill in the motion between two poses\nI choose. Neither of them ever draws anything. What comes out is a skeleton's joints moving\nover time, which gets filmed from the side, front or back, turned into angles on screen, and\nmapped onto our bones.</p>\n\n  <p>The sheets below show the whole trip in one picture: the human skeleton, the same moment laid\nover the creature's rig, the creature playing it, and what actually gets stored, one curve\nper channel.</p>\n\n</section>\n\n<figure style=\"max-width:none;margin-inline:auto;\">\n  <img src=\"../assets/img/pokewalker/maths-motion-charizard-takeoff-back.jpeg\" width=\"1920\" height=\"1133\" alt=\"An explainer sheet: a human skeleton crouching and leaping, the same frame laid over Charizard's back-view rig with each bone's angle marked, a row of Charizard frames taking off, and eight stored curves for the body and wings.\" />\n  <figcaption>\"A person crouches and leaps upward flapping their arms\", from behind. Each arm drives one wing, and the outer wing bones trail a frame or two behind so the wing bends through the stroke.</figcaption>\n</figure>\n\n<figure style=\"max-width:none;margin-inline:auto;\">\n  <img src=\"../assets/img/pokewalker/maths-motion-charizard-walk-side.jpeg\" width=\"1920\" height=\"1240\" alt=\"An explainer sheet: a human skeleton walking, the same frame over Charizard's side-view rig, a row of Charizard walking frames, and thirteen stored curves for body, head, arm, legs, tail and wing.\" />\n  <figcaption>A walk from the side. Thirteen tracks, each one traced back to the part of the human it came from.</figcaption>\n</figure>\n\n<figure style=\"max-width:none;margin-inline:auto;\">\n  <img src=\"../assets/img/pokewalker/maths-motion-nidoking-brace-snap.jpeg\" width=\"1920\" height=\"1175\" alt=\"An explainer sheet for Nidoking's brace: a human skeleton bracing, the same frame over Nidoking's front rig, a grid of Nidoking frames, and twenty-one stored curves, most with only three or four keys.\" />\n  <figcaption>The brace again, with its Kimodo reference shown faintly behind. The stored keys depart from it on purpose: the human gives the timing, the hand-set keys give the snap.</figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <p>That last one is how the methods actually get used together. The model is good at timing\nand weight. A few keys by hand are good at exaggeration, which a real person bracing doesn't\ndo and a cartoon dragon should.</p>\n\n  <h2>Keeping them</h2>\n\n  <p>Creatures get remade. The tracer improves, an eye gets fixed, the skeleton finder learns\nsomething, and the whole creature is built again from its sprites. A move that only lived in\nthe old file would be gone.</p>\n\n  <p>So moves that matter are kept as a log: a short text file of the motion commands that made\nthem. Every remake replays the log on top of the fresh creature, so the moves come back on\nthe new skeleton. For a creature that is already committed, a replay can add the logged moves\nto one view, Charizard's back, and leave every other byte of the file exactly as it was. That\nis how the flight moves went in without touching anything else Charizard does.</p>\n\n  <p>The flight moves also have fixed numbers: takeoff is 11, flap 12, glide 13, bank 14 and a\nbarrel roll 15. Bank is a scrub rather than a loop: fully left at its start, level in the\nmiddle, fully right at its end, and flight plays it at whatever angle the turn wants.</p>\n\n  <h2>It reaches the game</h2>\n\n  <p>Flight looks for those numbers. A flyer that has them takes off with its takeoff, beats its\nwings while it climbs or hurries, glides when it is level, fades between the two, and leans\ninto turns with its own bank instead of the whole picture tipping. A flyer that has none\nflies the way it always did. Charizard is the first to have them. Any creature given the same\nfive moves gets the same treatment, with no change to the flight code.</p>\n\n  <h2>What doesn't work yet</h2>\n\n  <p>The walker's followers are 32 pixels tall, so arms are three or four pixels. A punch or a\nwave moves almost nothing. Whole-body moves read; small-limb moves mostly don't.</p>\n\n  <p>Some limbs are still split out by hand. The generated skeleton sometimes keeps a leg as part\nof the body, and then there is nothing for a stride to turn. Splitting limbs automatically is\nbeing built now.</p>\n\n  <p>The turn between views isn't smooth yet. A creature going from side-on to facing away still\ncuts from one drawing to the next, and a proper turn is in progress.</p>\n\n</section>\n",
      "date_published": "2026-11-17T19:00:00+00:00"
    },
    {
      "id": "https://alchemy86.github.io/devlog/posts/new-moves-from-a-sentence.html",
      "url": "https://alchemy86.github.io/devlog/posts/new-moves-from-a-sentence.html",
      "title": "New moves from a sentence",
      "summary": "A text-to-motion model writes a human movement from a sentence, and the walker's maths Charizard performs it. It lost to our own walk and beat our own flight, so it is now how we author new moves, not how we replace the old ones.",
      "content_html": "<section class=\"prose\">\n\n  <p>Yesterday's creatures came with a handful of moves written by rule: a jump and spin, a\nbounce, a look round, a tail swish. Rules are good at small, tidy motions. They are bad at\nanything with weight and timing, like a body crouching, leaping and catching itself.</p>\n\n  <p>That is exactly what text-to-motion models are good at. <a href=\"https://github.com/localai-org/kimodo.cpp\">Kimodo</a>\nis one of them: NVIDIA's Kimodo model, ported to plain C++ by the LocalAI folks. You give it\na sentence and a length, and it gives back a skeleton moving at 30 frames a second. It runs\non an ordinary CPU, which is all I wanted to spend on it.</p>\n\n  <p>The catch is that it writes motion for a person. Thirty joints, two arms, two legs, a head\non a neck. Charizard has wings, a tail, stubby arms and a follower sprite 32 pixels tall.</p>\n\n  <h2>A person, seen from one side</h2>\n\n  <p>The trick is to stop thinking in 3D. A follower is never seen in 3D: it is a front, a side\nor a back, drawn flat. So the human is filmed from one of those directions, and each limb\nbecomes an angle on the screen.</p>\n\n  <p>From the side, the hips-to-neck line becomes Charizard's lean, the legs become its legs,\nand the way the body rises and falls feeds a lagging sway down the tail. From the front,\nthe arms become arms and the shoulders lift the wings. Which view to use is picked from the\nmotion itself: lots of forward-and-back limb movement means side on, lots of side-to-side\nmeans front on. When a limb points straight at the camera it has no usable angle, so it\nholds its last good one rather than flicking about.</p>\n\n  <p>Five sentences, onto the follower as the walker already rigs it:</p>\n\n</section>\n\n<figure style=\"margin-inline:auto;\">\n  <video controls=\"\" playsinline=\"\" preload=\"metadata\" poster=\"../assets/img/pokewalker/kimodo-five-prompts-poster.jpeg\" width=\"720\" height=\"244\">\n    <source src=\"../assets/video/pokewalker/kimodo-five-prompts.mp4\" type=\"video/mp4\" />\n  </video>\n  <figcaption>Walk and stop, stretch, punch, jump, and walk, turn and wave. Left: limbs split by hand. Right: the rig as the walker makes it.</figcaption>\n</figure>\n\n<figure style=\"max-width:none;margin-inline:auto;\">\n  <img src=\"../assets/img/pokewalker/kimodo-prompts-sheet.jpeg\" width=\"1872\" height=\"2170\" alt=\"Five rows of Charizard frames, one row per prompt, each shown on two rigs: walking and stopping, stretching, punching, jumping and turning to wave.\" />\n  <figcaption>The same five, frame by frame.</figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <p>The jump is lovely. He crouches, throws himself up and back, and the tail whips after him.\nWalking forward and stopping reads well too, because the stop is in the whole body.</p>\n\n  <p>The punch, the stretch and the wave do almost nothing. They are arm moves, and a\nfollower's arm is three or four pixels. There is nothing there to throw a punch with.</p>\n\n  <h2>It lost to our walk</h2>\n\n  <p>The obvious next question was whether Kimodo should simply take over the walk. It is a real\nwalk cycle from real motion data. Ours is two drawings swapped every 170 ms.</p>\n\n</section>\n\n<figure style=\"margin-inline:auto;\">\n  <video controls=\"\" playsinline=\"\" preload=\"metadata\" poster=\"../assets/img/pokewalker/kimodo-walk-compare-poster.jpeg\" width=\"720\" height=\"180\">\n    <source src=\"../assets/video/pokewalker/kimodo-walk-compare.mp4\" type=\"video/mp4\" />\n  </video>\n  <figcaption>Left: the walk the park uses today. Middle: Kimodo on the follower. Right: Kimodo with the legs split into their own bones.</figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <p>Ours wins. A human walks at a human pace, and on a creature this small that pace looks\nsluggish, like wading. The legs don't help either: at 32 pixels the feet are not separate\nenough to plant one and swing the other, even with the legs cut out by hand. The two\ndrawings were made by an artist who knew all that and cheated accordingly.</p>\n\n  <p>What Kimodo did add was the lean into each step and the sway of the tail. Nice, but not\nworth giving up a walk that already works.</p>\n\n  <h2>It won at flying</h2>\n\n  <p>Flight is a different story. The flyer is seen from behind, and today it flies by swapping\ntwo poses every 150 ms. From behind, a person flapping their arms maps straight onto a pair\nof wings: how high each arm is drives that wing, and each segment further out trails a frame\nor two behind, so the wing bends through the stroke instead of hinging.</p>\n\n</section>\n\n<figure style=\"margin-inline:auto;\">\n  <video controls=\"\" playsinline=\"\" preload=\"metadata\" poster=\"../assets/img/pokewalker/kimodo-fly-vs-now-poster.jpeg\" width=\"720\" height=\"266\">\n    <source src=\"../assets/video/pokewalker/kimodo-fly-vs-now.mp4\" type=\"video/mp4\" />\n  </video>\n  <figcaption>Left: flight today. Middle: \"flaps both arms up and down like wings\". Right: \"glides with arms spread out wide and leans left then right\".</figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <p>The glide is my favourite. Tilting the shoulders becomes a bank, so he leans into a turn,\nholds it, and leans out the other way. Nothing in the rule-written moves does that.</p>\n\n</section>\n\n<figure style=\"margin-inline:auto;\">\n  <video controls=\"\" playsinline=\"\" preload=\"metadata\" poster=\"../assets/img/pokewalker/kimodo-flap-poster.jpeg\" width=\"720\" height=\"402\">\n    <source src=\"../assets/video/pokewalker/kimodo-flap.mp4\" type=\"video/mp4\" />\n  </video>\n  <figcaption>The flap from behind, as flight draws it, and from the side.</figcaption>\n</figure>\n\n<figure style=\"max-width:none;margin-inline:auto;\">\n  <img src=\"../assets/img/pokewalker/kimodo-flight-sheet.jpeg\" width=\"2880\" height=\"1170\" alt=\"Three rows of Charizard flight frames over four seconds, each from behind and from the side: taking off, flapping, and gliding with a bank.\" />\n  <figcaption>Take-off, flap and glide over four seconds, from behind (top of each row) and the side.</figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <p>Take-off nearly works. The crouch and the leap read well. Then the person it came from\nlands, because people do, and Charizard pitches forward into a nose-dive. A take-off for a\ndragon wants a sentence where nobody comes back down.</p>\n\n  <h2>A tool for new moves, not a replacement</h2>\n\n  <p>So that settles where it fits. Kimodo doesn't replace any move the walker makes for a\ncreature. It adds new ones next to them: a flap, a glide, a jump, a celebration. You write\nthe sentence, look at the result on the actual creature, keep it if it reads, and throw it\naway if it doesn't. Throwing one away costs about a minute.</p>\n\n  <p>That minute is the real cost. A four-second clip takes around 75 seconds on all the cores\nof a desktop CPU and holds about 2.5 GB of memory while it thinks. The text model is the\nheavy half, so it loads two layers at a time instead of all of them, and a watchdog kills\nthe run if the machine starts running short. Nothing about it goes near the walker itself:\nwhat comes out is just keyframes on bones, the same as every other move.</p>\n\n  <p>The scripts live with the rest of the creature tools, and I've kept a fork of kimodo.cpp so\nthe build we used stays buildable. Next is the obvious one: a proper take-off, and some\nsentences written for a dragon rather than a person.</p>\n\n</section>\n",
      "date_published": "2026-11-17T16:00:00+00:00"
    },
    {
      "id": "https://alchemy86.github.io/devlog/posts/the-second-core-was-doing-nothing.html",
      "url": "https://alchemy86.github.io/devlog/posts/the-second-core-was-doing-nothing.html",
      "title": "The second core was doing nothing",
      "summary": "The walker now runs two to three times faster on the real board. The walking face went from 13.8 to 39.7 frames a second and the open world roughly doubled, by giving the ESP32-S3's idle second core the panel, the sensors and half the ground. Not one pixel changed.",
      "content_html": "<section class=\"prose\">\n\n  <p>The walker is an ESP32-S3 behind a round 412×412 screen. The software draws a 103×103\npicture and the board scales it up four times, so every dot is a crisp 4×4 block. Until\ntoday that ran at about 13 frames a second on the walking face and 7 or 8 in the open\nworld.</p>\n\n  <p>It now runs at 39.7 on the walking face, 36.5 with the closed ball spinning, and 14 to 19\nacross the open world. The drawing code did not get faster. The time went to the second\ncore.</p>\n\n</section>\n\n<figure class=\"scrollfig\" aria-labelledby=\"fig-fps-cap\">\n  <svg viewBox=\"0 0 720 406\" role=\"img\" aria-labelledby=\"fps-title\" xmlns=\"http://www.w3.org/2000/svg\" font-family=\"'JetBrains Mono', monospace\">\n      <title id=\"fps-title\">Frames a second on the board, before and after, for eight screens</title>\n      <style>\n        .gl { stroke: var(--hairline); stroke-width: 1; }\n        .ax { fill: var(--ink-soft); font-size: 10px; }\n        .lb { fill: var(--ink); font-size: 11.5px; }\n        .b0 { fill: var(--ink-soft); }\n        .b1 { fill: var(--accent); }\n        .v0 { fill: var(--ink-soft); font-size: 10px; }\n        .v1 { fill: var(--ink); font-size: 10.5px; font-weight: 700; }\n        .lg { fill: var(--ink-soft); font-size: 10.5px; font-weight: 700; letter-spacing: .08em; }\n      </style>\n      <rect x=\"200\" y=\"14\" width=\"12\" height=\"12\" rx=\"2\" class=\"b0\" /><text x=\"218\" y=\"24\" class=\"lg\">BEFORE</text>\n      <rect x=\"290\" y=\"14\" width=\"12\" height=\"12\" rx=\"2\" class=\"b1\" /><text x=\"308\" y=\"24\" class=\"lg\">AFTER</text>\n      <line x1=\"200.0\" y1=\"46\" x2=\"200.0\" y2=\"372\" class=\"gl\" /><text x=\"200.0\" y=\"388\" text-anchor=\"middle\" class=\"ax\">0</text>\n      <line x1=\"315.0\" y1=\"46\" x2=\"315.0\" y2=\"372\" class=\"gl\" /><text x=\"315.0\" y=\"388\" text-anchor=\"middle\" class=\"ax\">10</text>\n      <line x1=\"430.0\" y1=\"46\" x2=\"430.0\" y2=\"372\" class=\"gl\" /><text x=\"430.0\" y=\"388\" text-anchor=\"middle\" class=\"ax\">20</text>\n      <line x1=\"545.0\" y1=\"46\" x2=\"545.0\" y2=\"372\" class=\"gl\" /><text x=\"545.0\" y=\"388\" text-anchor=\"middle\" class=\"ax\">30</text>\n      <line x1=\"660.0\" y1=\"46\" x2=\"660.0\" y2=\"372\" class=\"gl\" /><text x=\"660.0\" y=\"388\" text-anchor=\"middle\" class=\"ax\">40</text>\n      <text x=\"660\" y=\"402\" text-anchor=\"end\" class=\"ax\">frames a second</text>\n      <g><title>Closed ball, spinning: 13.2 fps before, 36.5 after (2.8x)</title>\n        <text x=\"190\" y=\"75\" text-anchor=\"end\" class=\"lb\">Closed ball, spinning</text>\n        <rect x=\"200\" y=\"58\" width=\"151.8\" height=\"12\" rx=\"2\" class=\"b0\" /><text x=\"356.8\" y=\"68\" class=\"v0\">13.2</text>\n        <rect x=\"200\" y=\"72\" width=\"419.8\" height=\"12\" rx=\"2\" class=\"b1\" /><text x=\"624.8\" y=\"82\" class=\"v1\">36.5</text>\n      </g>\n      <g><title>Walking face: 13.8 fps before, 39.7 after (2.9x)</title>\n        <text x=\"190\" y=\"115\" text-anchor=\"end\" class=\"lb\">Walking face</text>\n        <rect x=\"200\" y=\"98\" width=\"158.7\" height=\"12\" rx=\"2\" class=\"b0\" /><text x=\"363.7\" y=\"108\" class=\"v0\">13.8</text>\n        <rect x=\"200\" y=\"112\" width=\"456.6\" height=\"12\" rx=\"2\" class=\"b1\" /><text x=\"661.5\" y=\"122\" class=\"v1\">39.7</text>\n      </g>\n      <g><title>Quick battle: 12.1 fps before, 24.3 after (2.0x)</title>\n        <text x=\"190\" y=\"155\" text-anchor=\"end\" class=\"lb\">Quick battle</text>\n        <rect x=\"200\" y=\"138\" width=\"139.2\" height=\"12\" rx=\"2\" class=\"b0\" /><text x=\"344.1\" y=\"148\" class=\"v0\">12.1</text>\n        <rect x=\"200\" y=\"152\" width=\"279.4\" height=\"12\" rx=\"2\" class=\"b1\" /><text x=\"484.4\" y=\"162\" class=\"v1\">24.3</text>\n      </g>\n      <g><title>Park plaza: 8.1 fps before, 15.1 after (1.9x)</title>\n        <text x=\"190\" y=\"195\" text-anchor=\"end\" class=\"lb\">Park plaza</text>\n        <rect x=\"200\" y=\"178\" width=\"93.1\" height=\"12\" rx=\"2\" class=\"b0\" /><text x=\"298.1\" y=\"188\" class=\"v0\">8.1</text>\n        <rect x=\"200\" y=\"192\" width=\"173.7\" height=\"12\" rx=\"2\" class=\"b1\" /><text x=\"378.6\" y=\"202\" class=\"v1\">15.1</text>\n      </g>\n      <g><title>Gate road, standing: 7.5 fps before, 15.7 after (2.1x)</title>\n        <text x=\"190\" y=\"235\" text-anchor=\"end\" class=\"lb\">Gate road, standing</text>\n        <rect x=\"200\" y=\"218\" width=\"86.2\" height=\"12\" rx=\"2\" class=\"b0\" /><text x=\"291.2\" y=\"228\" class=\"v0\">7.5</text>\n        <rect x=\"200\" y=\"232\" width=\"180.5\" height=\"12\" rx=\"2\" class=\"b1\" /><text x=\"385.5\" y=\"242\" class=\"v1\">15.7</text>\n      </g>\n      <g><title>Gate road, walking: 6.7 fps before, 14.1 after (2.1x)</title>\n        <text x=\"190\" y=\"275\" text-anchor=\"end\" class=\"lb\">Gate road, walking</text>\n        <rect x=\"200\" y=\"258\" width=\"77.0\" height=\"12\" rx=\"2\" class=\"b0\" /><text x=\"282.1\" y=\"268\" class=\"v0\">6.7</text>\n        <rect x=\"200\" y=\"272\" width=\"162.2\" height=\"12\" rx=\"2\" class=\"b1\" /><text x=\"367.1\" y=\"282\" class=\"v1\">14.1</text>\n      </g>\n      <g><title>Cerulean, standing: 7.3 fps before, 15.4 after (2.1x)</title>\n        <text x=\"190\" y=\"315\" text-anchor=\"end\" class=\"lb\">Cerulean, standing</text>\n        <rect x=\"200\" y=\"298\" width=\"84.0\" height=\"12\" rx=\"2\" class=\"b0\" /><text x=\"288.9\" y=\"308\" class=\"v0\">7.3</text>\n        <rect x=\"200\" y=\"312\" width=\"177.1\" height=\"12\" rx=\"2\" class=\"b1\" /><text x=\"382.1\" y=\"322\" class=\"v1\">15.4</text>\n      </g>\n      <g><title>Cerulean, walking: 8.7 fps before, 19.0 after (2.2x)</title>\n        <text x=\"190\" y=\"355\" text-anchor=\"end\" class=\"lb\">Cerulean, walking</text>\n        <rect x=\"200\" y=\"338\" width=\"100.0\" height=\"12\" rx=\"2\" class=\"b0\" /><text x=\"305.1\" y=\"348\" class=\"v0\">8.7</text>\n        <rect x=\"200\" y=\"352\" width=\"218.5\" height=\"12\" rx=\"2\" class=\"b1\" /><text x=\"423.5\" y=\"362\" class=\"v1\">19.0</text>\n      </g>\n    </svg>\n  <figcaption id=\"fig-fps-cap\">\n    Frames a second on the board, three runs each. The gate road and Cerulean are two places\n    in the open region around the park, measured standing still and walking.\n  </figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <h2>Where a frame went</h2>\n\n  <p>The first change was a line of numbers. Every few seconds the board now prints how long\neach part of the frame took. On the closed ball it read: 23.2 ms drawing, 18.8 ms\nencoding the picture into the panel's colour format, 19.2 ms sending it, and 11.3 ms\nreading the touch panel. All on core 0, in a row.</p>\n\n  <p>Core 1 ran the speaker and nothing else. It was idle about 90% of the time.</p>\n\n</section>\n\n<figure class=\"scrollfig\" aria-labelledby=\"fig-tl-cap\">\n  <svg viewBox=\"0 0 720 360\" role=\"img\" aria-labelledby=\"tl-title\" xmlns=\"http://www.w3.org/2000/svg\" font-family=\"'JetBrains Mono', monospace\">\n      <title id=\"tl-title\">One frame on the closed ball, before and after: four jobs in a row on core 0, then core 0 drawing while core 1 sends</title>\n      <style>\n        .sg { fill: var(--code-bg); stroke: var(--hairline); stroke-width: 1.5; }\n        .dr { fill: var(--card); stroke: var(--accent); stroke-width: 2; }\n        .id { fill: none; stroke: var(--hairline); stroke-width: 1.5; stroke-dasharray: 4 4; }\n        .st { fill: var(--ink); font-size: 11px; font-weight: 700; }\n        .sm { fill: var(--ink-soft); font-size: 10px; }\n        .ln { fill: var(--ink); font-size: 11px; font-weight: 700; }\n        .hd { fill: var(--accent); font-size: 10.5px; font-weight: 700; letter-spacing: .1em; }\n        .gl { stroke: var(--hairline); stroke-width: 1; }\n        .ax { fill: var(--ink-soft); font-size: 10px; }\n        .fr { stroke: var(--ink); stroke-width: 2; }\n      </style>\n      <text x=\"8\" y=\"18\" class=\"hd\">BEFORE — 13.2 FRAMES A SECOND</text>\n      <text x=\"8\" y=\"51\" class=\"ln\">core 0</text>\n      <rect x=\"120.0\" y=\"30\" width=\"166.2\" height=\"34\" rx=\"4\" class=\"dr\" />\n      <text x=\"204.1\" y=\"45\" text-anchor=\"middle\" class=\"st\">draw</text>\n      <text x=\"204.1\" y=\"58\" text-anchor=\"middle\" class=\"sm\">23.2 ms</text>\n      <rect x=\"288.2\" y=\"30\" width=\"134.3\" height=\"34\" rx=\"4\" class=\"sg\" />\n      <text x=\"356.4\" y=\"45\" text-anchor=\"middle\" class=\"st\">encode</text>\n      <text x=\"356.4\" y=\"58\" text-anchor=\"middle\" class=\"sm\">18.8 ms</text>\n      <rect x=\"424.5\" y=\"30\" width=\"137.2\" height=\"34\" rx=\"4\" class=\"sg\" />\n      <text x=\"494.1\" y=\"45\" text-anchor=\"middle\" class=\"st\">send</text>\n      <text x=\"494.1\" y=\"58\" text-anchor=\"middle\" class=\"sm\">19.2 ms</text>\n      <rect x=\"563.7\" y=\"30\" width=\"79.9\" height=\"34\" rx=\"4\" class=\"sg\" />\n      <text x=\"604.7\" y=\"45\" text-anchor=\"middle\" class=\"st\">touch</text>\n      <text x=\"604.7\" y=\"58\" text-anchor=\"middle\" class=\"sm\">11.3 ms</text>\n      <rect x=\"645.6\" y=\"30\" width=\"52.4\" height=\"34\" rx=\"4\" class=\"dr\" />\n      <line x1=\"644.6\" y1=\"24\" x2=\"644.6\" y2=\"70\" class=\"fr\" />\n      <text x=\"8\" y=\"95\" class=\"ln\">core 1</text>\n      <rect x=\"120.0\" y=\"74\" width=\"578.0\" height=\"34\" rx=\"4\" class=\"id\" />\n      <text x=\"410.0\" y=\"95\" text-anchor=\"middle\" class=\"sm\">speaker only, idle about 90% of the time</text>\n      <text x=\"8\" y=\"160\" class=\"hd\">AFTER — 36.5 FRAMES A SECOND</text>\n      <text x=\"8\" y=\"193\" class=\"ln\">core 0</text>\n      <rect x=\"120.0\" y=\"172\" width=\"169.1\" height=\"34\" rx=\"4\" class=\"dr\" />\n      <text x=\"205.6\" y=\"187\" text-anchor=\"middle\" class=\"st\">draw</text>\n      <text x=\"205.6\" y=\"200\" text-anchor=\"middle\" class=\"sm\">23.6 ms</text>\n      <line x1=\"317.6\" y1=\"166\" x2=\"317.6\" y2=\"212\" class=\"fr\" />\n      <rect x=\"318.6\" y=\"172\" width=\"169.1\" height=\"34\" rx=\"4\" class=\"dr\" />\n      <text x=\"404.2\" y=\"187\" text-anchor=\"middle\" class=\"st\">draw</text>\n      <text x=\"404.2\" y=\"200\" text-anchor=\"middle\" class=\"sm\">23.6 ms</text>\n      <line x1=\"516.3\" y1=\"166\" x2=\"516.3\" y2=\"212\" class=\"fr\" />\n      <rect x=\"517.3\" y=\"172\" width=\"169.1\" height=\"34\" rx=\"4\" class=\"dr\" />\n      <text x=\"602.8\" y=\"187\" text-anchor=\"middle\" class=\"st\">draw</text>\n      <text x=\"602.8\" y=\"200\" text-anchor=\"middle\" class=\"sm\">23.6 ms</text>\n      <text x=\"8\" y=\"237\" class=\"ln\">core 1</text>\n      <rect x=\"298.4\" y=\"216\" width=\"17.6\" height=\"34\" rx=\"4\" class=\"sg\" />\n      <rect x=\"317.9\" y=\"216\" width=\"111.8\" height=\"34\" rx=\"4\" class=\"sg\" />\n      <text x=\"374.8\" y=\"231\" text-anchor=\"middle\" class=\"st\">send</text>\n      <text x=\"374.8\" y=\"244\" text-anchor=\"middle\" class=\"sm\">15.7 ms</text>\n      <rect x=\"497.0\" y=\"216\" width=\"17.6\" height=\"34\" rx=\"4\" class=\"sg\" />\n      <rect x=\"516.6\" y=\"216\" width=\"111.8\" height=\"34\" rx=\"4\" class=\"sg\" />\n      <text x=\"573.5\" y=\"231\" text-anchor=\"middle\" class=\"st\">send</text>\n      <text x=\"573.5\" y=\"244\" text-anchor=\"middle\" class=\"sm\">15.7 ms</text>\n      <text x=\"298.4\" y=\"266\" class=\"sm\">encode 2.7 ms</text>\n      <text x=\"120.0\" y=\"286\" class=\"sm\">touch and motion sensor read here, during the draw</text>\n      <rect x=\"141.8\" y=\"216\" width=\"6\" height=\"34\" rx=\"2\" class=\"sg\" />\n      <rect x=\"185.2\" y=\"216\" width=\"6\" height=\"34\" rx=\"2\" class=\"sg\" />\n      <rect x=\"228.8\" y=\"216\" width=\"6\" height=\"34\" rx=\"2\" class=\"sg\" />\n      <line x1=\"120.0\" y1=\"316\" x2=\"120.0\" y2=\"322\" class=\"gl\" /><text x=\"120.0\" y=\"336\" text-anchor=\"middle\" class=\"ax\">0</text>\n      <line x1=\"192.5\" y1=\"316\" x2=\"192.5\" y2=\"322\" class=\"gl\" /><text x=\"192.5\" y=\"336\" text-anchor=\"middle\" class=\"ax\">10</text>\n      <line x1=\"265.0\" y1=\"316\" x2=\"265.0\" y2=\"322\" class=\"gl\" /><text x=\"265.0\" y=\"336\" text-anchor=\"middle\" class=\"ax\">20</text>\n      <line x1=\"337.5\" y1=\"316\" x2=\"337.5\" y2=\"322\" class=\"gl\" /><text x=\"337.5\" y=\"336\" text-anchor=\"middle\" class=\"ax\">30</text>\n      <line x1=\"410.0\" y1=\"316\" x2=\"410.0\" y2=\"322\" class=\"gl\" /><text x=\"410.0\" y=\"336\" text-anchor=\"middle\" class=\"ax\">40</text>\n      <line x1=\"482.5\" y1=\"316\" x2=\"482.5\" y2=\"322\" class=\"gl\" /><text x=\"482.5\" y=\"336\" text-anchor=\"middle\" class=\"ax\">50</text>\n      <line x1=\"555.0\" y1=\"316\" x2=\"555.0\" y2=\"322\" class=\"gl\" /><text x=\"555.0\" y=\"336\" text-anchor=\"middle\" class=\"ax\">60</text>\n      <line x1=\"627.5\" y1=\"316\" x2=\"627.5\" y2=\"322\" class=\"gl\" /><text x=\"627.5\" y=\"336\" text-anchor=\"middle\" class=\"ax\">70</text>\n      <line x1=\"700.0\" y1=\"316\" x2=\"700.0\" y2=\"322\" class=\"gl\" /><text x=\"700.0\" y=\"336\" text-anchor=\"middle\" class=\"ax\">80</text>\n      <line x1=\"120.0\" y1=\"316\" x2=\"700.0\" y2=\"316\" class=\"gl\" />\n      <text x=\"700.0\" y=\"352\" text-anchor=\"end\" class=\"ax\">milliseconds · a vertical line starts the next frame</text>\n    </svg>\n  <figcaption id=\"fig-tl-cap\">\n    One frame on the closed ball, to scale. Before, core 0 does four jobs in a row. After,\n    it only draws, and core 1 encodes and sends the last frame while the next is drawn.\n  </figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <h2>One table instead of a lookup per pixel</h2>\n\n  <p>The canvas stores each pixel as one of 256 shades. Turning a shade into the bytes the\npanel wants meant working out its colour every time, for every pixel. But within one frame a\nshade is always the same colour.</p>\n\n  <p>So once a frame the walker builds a table: all 256 shades, each already encoded as the\nfour panel dots it becomes. A row of the picture is then a run of table lookups.\nEncoding fell from 18.8 ms to 2.5 ms on that change alone.</p>\n\n  <h2>Sending from the other core</h2>\n\n  <p>This was the biggest win. When core 0 finishes a picture, it copies the canvas into a\nsnapshot in PSRAM and posts it to core 1 through a one-slot mailbox. Then it goes straight\non to the next frame. Core 1 encodes the snapshot band by band and puts it on the wire.</p>\n\n  <p>Neither side takes a lock. Core 0 only writes the mailbox when it is empty, and core 1\nonly reads it when it is full. Core 1 never prints either, so when a save to flash parks\nit mid-frame, the frame is late and nothing else happens.</p>\n\n  <p>The bytes on the wire are the same as before: the same windows, the same transactions, in\nthe same order. Only the core sending them changed.</p>\n\n  <p>Then the band buffers were doubled. Each band now goes out as two halves from two pairs of\nDMA buffers, so the next half is encoded while the last one is on the wire.</p>\n\n  <p>There is a floor here. The panel's bus runs at 40 MHz on four lanes, the ceiling its\ndatasheet gives for it, and a full 412×412 frame takes about 16 ms to cross it. The send is now\n15.7 ms. That is the bus, not the code.</p>\n\n  <h2>Sharing the ground</h2>\n\n  <p>The open world spends most of its frame on the ground: the grass, paths and water drawn\nrow by row in perspective. Those rows do not depend on each other, so the two cores can\nsplit them.</p>\n\n  <p>Both cores take the next row from one shared counter until none are left. Each row is\nwritten into a buffer, and when every row is done, core 0 copies them into the canvas in\nthe same order, left to right and top to bottom, that the one-core drawing uses. The\npicture cannot change, only when it is ready.</p>\n\n  <p>With this and the changes above, the park plaza went from 8.1 to 15.1 frames a second. The battle arena's floor is\ndrawn the same way now, for a smaller gain.</p>\n\n  <h2>The one that went backwards</h2>\n\n  <p>The spinning closed ball got the same treatment and came out slower on the board. Core 1\nis busy sending the previous frame for most of the time the ball is being drawn, so\nhanding it rows only made core 0 wait. It was taken back out.</p>\n\n  <h2>Reading the sensors in the gaps</h2>\n\n  <p>The touch panel and the accelerometer share one I2C bus. They used to be read between\nbands of the panel transfer, and the transfer had moved to core 1. Leaving the reads on\ncore 0 meant none during a long draw, and the open world's draw is 50 ms and more. The\nstep counter wants a sample at least 25 times a second.</p>\n\n  <p>So while core 0 draws, it lends core 1 the bus. Core 1 reads both sensors on the usual\ncadence, between its own bands and rows, and keeps each reading with the time it was\ntaken. When the picture is done, core 0 takes the bus back and replays the readings\nthrough exactly the code it would have run had it read them itself, at those times.</p>\n\n  <p>Touch no longer costs core 0 anything: 11.3 ms became 0. The accelerometer is now read at\nabout 65 times a second everywhere, up from 30 to 38 in the park.</p>\n\n  <h2>Nothing on the screen changed</h2>\n\n  <p>Every golden frame the test suite keeps is unchanged, and so is the hash of the whole\npixel battle. Tests that draw the same pictures with the work split across two threads\nget identical frames. The speaker ran through all of it with no underruns.</p>\n\n  <p>Those checks read the canvas, the picture as the software holds it. Nobody has yet looked\nat the physical panel after this change, so the last step, from the bytes on the wire to\nthe glass, is still to be seen.</p>\n\n  <h2>What is left</h2>\n\n  <ul>\n    <li>The park's standing objects still take about 27 ms, all on core 0.</li>\n    <li>The walking face and the closed ball are now bound by core 0's own draw, about 23 ms.</li>\n    <li>The S3's vector instructions have not been tried on any of it.</li>\n  </ul>\n\n  <p>The battles this speeds up are the ones in <a href=\"the-stadium-shakes.html\">the stadium post</a>,\nand the rest of the device is on <a href=\"../projects/pokewalker.html\">the project page</a>.</p>\n\n</section>\n",
      "date_published": "2026-11-16T22:00:00+00:00"
    },
    {
      "id": "https://alchemy86.github.io/devlog/posts/a-pokemon-made-of-maths.html",
      "url": "https://alchemy86.github.io/devlog/posts/a-pokemon-made-of-maths.html",
      "title": "A Pokémon made of maths",
      "summary": "The walker can now turn a sprite sheet into a creature made of curves, a skeleton and motion: no pixels stored, drawn fresh every frame. Charizard, Pikachu and Bulbasaur are rigged, animated and drawn in two line styles from the same data.",
      "content_html": "<section class=\"prose\">\n\n  <p>A sprite is a grid of coloured squares. It cannot bend its tail, turn its head or curl into\na ball. Everything a sprite does, an artist drew frame by frame.</p>\n\n  <p>So the walker now reads a sprite the way an animator would. It traces each part as smooth\noutlines, works out where the body, head, tail and limbs are, and puts a skeleton inside.\nFrom then on the creature is data: curves on bones, drawn fresh on every frame.</p>\n\n  <h2>The skeleton finds itself</h2>\n\n</section>\n\n<figure style=\"margin-inline:auto;\">\n  <img src=\"../assets/img/pokewalker/rig-charizard.jpeg\" width=\"1408\" height=\"800\" alt=\"Charizard with 32 bones in 10 chains drawn over the sprite, each chain a colour, with its joint limits listed beside it.\" />\n  <figcaption>Charizard: 32 bones in 10 chains. The neck, the five-bone tail, both wings, arms and legs.</figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <p>Nobody placed these bones. The rig comes from the sprite sheet itself. The front view gives\nthe rest pose. The game's second frame, laid over it, shows what moves and how far. The\n32×32 walking sprites show how much moves at each joint as it walks.</p>\n\n  <p>Each chain gets a role (spine, neck, head, tail, wing, arm, leg) and a limit for every\njoint, so a wing can sweep but an elbow cannot fold backwards. The format has a budget of\n32 bones. Charizard hits it, so a few one-bone twigs are left out and say so in the table.</p>\n\n</section>\n\n<figure style=\"margin-inline:auto;\">\n  <img src=\"../assets/img/pokewalker/rig-charizard-parts.jpeg\" width=\"1232\" height=\"640\" alt=\"Charizard's body split into coloured parts, each shaded by the bone that owns it.\" />\n  <figcaption>Which bone owns which part of the body. This is what bends when a bone turns.</figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <p>Pikachu gets the same treatment from the same code: 30 bones, the ears as their own chains,\nthe zigzag tail as a long one.</p>\n\n</section>\n\n<div class=\"fig-pair\" style=\"max-width:none;\">\n  <figure>\n    <img src=\"../assets/img/pokewalker/rig-pikachu.jpeg\" width=\"976\" height=\"448\" alt=\"Pikachu's sprite with 30 bones in 11 chains drawn over it.\" />\n    <figcaption>Pikachu's skeleton over the sprite.</figcaption>\n  </figure>\n  <figure>\n    <img src=\"../assets/img/pokewalker/rig-pikachu-parts.jpeg\" width=\"976\" height=\"448\" alt=\"Pikachu split into coloured parts, one per chain.\" />\n    <figcaption>And the parts each chain moves.</figcaption>\n  </figure>\n</div>\n\n<section class=\"prose\">\n\n  <h2>Eyes are their own check</h2>\n\n  <p>An eye is a dozen pixels out of a thousand. Lose one and the outline still matches almost\nperfectly, but the creature looks dead. So eyes are checked on their own: found, not\nhollow, and not covered by another part in any pose of any move. A creature that fails is\nnot finished.</p>\n\n  <p>Finding eyes is the hard part. The finder is right on about three species in five. Here it\nis across twenty random ones, with each species' boxes and verdict.</p>\n\n</section>\n\n<figure style=\"max-width:none;margin-inline:auto;\">\n  <img src=\"../assets/img/pokewalker/eye-finder-sheet.jpeg\" width=\"2016\" height=\"1490\" alt=\"Twenty Pokémon, each shown as source sprite, second frame and the maths version, with the eye finder's boxes and a pass or fail line.\" />\n  <figcaption>Source, second frame, and ours, for twenty species. Green is a pass, red a miss.</figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <h2>Moving, and redrawn</h2>\n\n  <p>Once there is a skeleton, a move is a set of eased curves on bones over time. Moves are\nwritten once and work on any creature: a jump and spin, a bounce, a look round, a slow tail\nswish, a sleepy sway, and now a ball spin, where it curls up, spins with sparks and lands.</p>\n\n  <p>Because nothing is stored as pixels, the line style is a choice made at draw time. These\ntwo clips are the same data drawn bold and thin, side by side.</p>\n\n</section>\n\n<figure style=\"margin-inline:auto;\">\n  <video controls=\"\" playsinline=\"\" preload=\"metadata\" poster=\"../assets/img/pokewalker/maths-charizard-bold-thin-poster.png\" width=\"2112\" height=\"1028\">\n    <source src=\"../assets/video/pokewalker/maths-charizard-bold-thin.mp4\" type=\"video/mp4\" />\n  </video>\n  <figcaption>Charizard as shapes, idling. Bold lines and thin lines from the same file.</figcaption>\n</figure>\n\n<figure style=\"margin-inline:auto;\">\n  <video controls=\"\" playsinline=\"\" preload=\"metadata\" poster=\"../assets/img/pokewalker/maths-bulbasaur-bold-thin-poster.png\" width=\"960\" height=\"516\">\n    <source src=\"../assets/video/pokewalker/maths-bulbasaur-bold-thin.mp4\" type=\"video/mp4\" />\n  </video>\n  <figcaption>Bulbasaur, the same way.</figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <h2>Small enough for the walker</h2>\n\n  <p>Charizard as shapes is 14.5 KB, Pikachu 8.1 KB and Bulbasaur 5.2 KB, each covering both of\nthe game's frames and every move. The renderer that draws them is integer-only and\nallocates nothing while drawing, so it runs on the walker's own chip, not just on a desktop.</p>\n\n  <p>What it cannot do yet: the back of Charizard, built from tiny 32-pixel walking frames, is\nstill rough, and the eye finder misses two species in five.</p>\n\n</section>\n",
      "date_published": "2026-11-16T15:30:00+00:00"
    },
    {
      "id": "https://alchemy86.github.io/devlog/posts/a-minute-on-the-glass.html",
      "url": "https://alchemy86.github.io/devlog/posts/a-minute-on-the-glass.html",
      "title": "A minute on the glass",
      "summary": "A sixty-second film of the Pokewalker: the round Poké Ball turning on a reflective floor while the walker's own screen plays on its glass. Pet mode, Surfing Pikachu, wild areas, sixteen gym leaders, stadium battles and the shared park, all from the real software.",
      "content_html": "<figure style=\"max-width:380px;margin-inline:auto;\">\n  <video controls=\"\" playsinline=\"\" preload=\"metadata\" poster=\"../assets/img/pokewalker/pokewalker-promo-mobile-poster.png\" width=\"720\" height=\"1280\">\n    <source src=\"../assets/video/pokewalker/pokewalker-promo-mobile.mp4\" type=\"video/mp4\" />\n  </video>\n  <figcaption>The Pokewalker promo. Sound on.</figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <h2>What's in it</h2>\n\n  <ul>\n    <li>The ball shakes, opens on Pikachu and rolls through the team to Charizard, then drops\ninto pet mode in Gold's bedroom.</li>\n    <li>Surfing Pikachu, the wild areas, and moves played on the walking face with their own\nanimations.</li>\n    <li>The sixteen gym leaders, Kanto then Johto.</li>\n    <li>Stadium battles: Surf, Earthquake and Thunder, a beam clash in the middle of the field,\nand a knockout.</li>\n    <li>The shared park, live, and a RALLY race.</li>\n  </ul>\n\n  <p>The score under it is chip and synth, written for the film.</p>\n\n  <h2>How it was made</h2>\n\n  <p>The ball is the printed shell, rendered in Blender, turning on a reflective floor. Its\nscreen is not a mock-up. Every scene on the glass was recorded from the walker's Rust\nsoftware at its native 412×412, so what plays on the ball is what the walker draws.</p>\n\n  <p>The battle that ends the film runs a little longer on its own: two ordinary hits, the clash,\nand the knockout.</p>\n\n</section>\n\n<figure style=\"max-width:380px;margin-inline:auto;\">\n  <video controls=\"\" playsinline=\"\" preload=\"metadata\" poster=\"../assets/img/pokewalker/battle-epic-ko-poster.png\" width=\"720\" height=\"1280\">\n    <source src=\"../assets/video/pokewalker/battle-epic-ko.mp4\" type=\"video/mp4\" />\n  </video>\n  <figcaption>Flamethrower and Body Slam into a clash, then a double critical hit for the K.O.</figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <h2>The rest of it</h2>\n\n  <p>The film shows a minute of a much bigger thing. The <a href=\"../projects/pokewalker.html\">project page</a>\nhas all of it: the hardware and the shell, the games ring, battles and gyms, RALLY, the park,\nthe link-cable trade, the portal, and what is coming next.</p>\n\n</section>\n",
      "date_published": "2026-11-15T10:30:00+00:00"
    },
    {
      "id": "https://alchemy86.github.io/devlog/posts/the-leader-reads-your-team.html",
      "url": "https://alchemy86.github.io/devlog/posts/the-leader-reads-your-team.html",
      "title": "The leader reads your team",
      "summary": "Sixteen gym leaders on the Pokewalker, each in a stadium built in their own style. You earn a challenge by walking, Kanto first and then Johto, the leader sizes up the team you bring and builds theirs to stay just ahead of you, and the badge you win is worth looking at.",
      "content_html": "<section class=\"prose\">\n\n  <h2>Sixteen leaders, sixteen arenas</h2>\n\n  <p>Every leader from Kanto and Johto, Brock to Clair, fights in a stadium built in their own\nstyle. The field, the lines and the three lanes are the same everywhere, so a battle plays\nthe same; what changes is everything around it.</p>\n\n</section>\n\n<figure style=\"margin-inline:auto;\">\n  <video controls=\"\" preload=\"metadata\" poster=\"../assets/img/pokewalker/gym-tour-poster.png\" width=\"480\" height=\"480\">\n    <source src=\"../assets/video/pokewalker/gym-tour.mp4\" type=\"video/mp4\" />\n  </video>\n  <figcaption>Every leader's entrance from Brock to Clair, Morty's and Surge's in full, then Blaine's whole fight in the volcano and all sixteen badges.</figcaption>\n</figure>\n\n<figure class=\"pixel\" style=\"margin-inline:auto;max-width:620px;\">\n  <img src=\"../assets/img/pokewalker/gym-arenas.png\" width=\"1236\" height=\"1344\" alt=\"Sixteen round screens in a grid, one per gym, each with the leader's ace facing Bulbasaur: Kanto's two rows first, Brock's rocky floor, Misty's pool, Surge's steel plate, Erika's garden, Janine's dojo, Sabrina's violet hall, Blaine's lava crater and Blue's green court, then Johto's, Falkner's wooden deck, Bugsy's forest, Whitney's pink arena, Morty's dark shrine, Chuck's dojo, Jasmine's deck by the sea, Pryce's ice rink and Clair's flooded cave.\" />\n  <figcaption>The sixteen arenas from the battle camera, in challenge order.</figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <p>Brock fights on a rocky floor. Misty fights over a pool, Surge on a steel plate with\ncircuits running through it and a barrier that arcs, Erika in a garden of blossom, Sabrina\nin a violet hall where the rings pulse. Blaine fights in a volcano: the floor is cracked\nbasalt with lava moving underneath, and embers drift up the crater wall. In Johto, Falkner\nfights on a wooden deck high above the mountains, with birds overhead. Bugsy's field is a\nforest floor under falling leaves. Morty's shrine is dark boards and red gates with fog\ndrifting across it. Jasmine's lighthouse turns its beam over the sea at dusk, and Pryce's\nfloor is an ice rink in falling snow.</p>\n\n  <h2>Getting there</h2>\n\n  <p>You don't get to walk into a gym. Leaders come region by region, in the games' own order:\nKanto first, starting with Brock, then Johto. Each one asks for two things before you can\nchallenge them: steps walked since your last badge, and enough Pokémon on your team. There\nis no level requirement. How strong you are is the leader's problem, not the gate's.</p>\n\n  <table>\n    <thead>\n      <tr>\n        <th>Region</th>\n        <th>Leader</th>\n        <th>Steps since last badge</th>\n        <th>Team</th>\n      </tr>\n    </thead>\n    <tbody>\n      <tr>\n        <td>Kanto</td>\n        <td>Brock</td>\n        <td>500</td>\n        <td>1</td>\n      </tr>\n      <tr>\n        <td> </td>\n        <td>Misty</td>\n        <td>1,000</td>\n        <td>1</td>\n      </tr>\n      <tr>\n        <td> </td>\n        <td>Surge</td>\n        <td>1,500</td>\n        <td>2</td>\n      </tr>\n      <tr>\n        <td> </td>\n        <td>Erika</td>\n        <td>2,000</td>\n        <td>2</td>\n      </tr>\n      <tr>\n        <td> </td>\n        <td>Janine</td>\n        <td>2,500</td>\n        <td>2</td>\n      </tr>\n      <tr>\n        <td> </td>\n        <td>Sabrina</td>\n        <td>3,000</td>\n        <td>3</td>\n      </tr>\n      <tr>\n        <td> </td>\n        <td>Blaine</td>\n        <td>3,500</td>\n        <td>3</td>\n      </tr>\n      <tr>\n        <td> </td>\n        <td>Blue</td>\n        <td>4,000</td>\n        <td>3</td>\n      </tr>\n      <tr>\n        <td>Johto</td>\n        <td>Falkner</td>\n        <td>5,000</td>\n        <td>3</td>\n      </tr>\n      <tr>\n        <td> </td>\n        <td>Bugsy</td>\n        <td>5,000</td>\n        <td>4</td>\n      </tr>\n      <tr>\n        <td> </td>\n        <td>Whitney</td>\n        <td>6,000</td>\n        <td>4</td>\n      </tr>\n      <tr>\n        <td> </td>\n        <td>Morty</td>\n        <td>6,000</td>\n        <td>4</td>\n      </tr>\n      <tr>\n        <td> </td>\n        <td>Chuck</td>\n        <td>7,000</td>\n        <td>4</td>\n      </tr>\n      <tr>\n        <td> </td>\n        <td>Jasmine</td>\n        <td>7,000</td>\n        <td>5</td>\n      </tr>\n      <tr>\n        <td> </td>\n        <td>Pryce</td>\n        <td>8,000</td>\n        <td>5</td>\n      </tr>\n      <tr>\n        <td> </td>\n        <td>Clair</td>\n        <td>10,000</td>\n        <td>6</td>\n      </tr>\n    </tbody>\n  </table>\n\n  <p>That's 72,000 steps from the first badge to the last. The battle menu tells you what's\nstill missing (\"WALK 2,000 MORE\", \"NEED 3 POKEMON\") and the walking screen announces it\nwhen the next leader is ready for you.</p>\n\n  <p>Lose, and that leader rests until tomorrow. You can't grind a gym; you come back.</p>\n\n  <h2>The leader reads your team</h2>\n\n  <p>When you arrive, the leader looks at what you've brought: how many Pokémon, how strong your\nbest one is, whether any of them can hit the gym's type hard, how many badges you already\nhold and how you've been doing in battle. From that they decide what kind of trainer you\nare: <strong>rookie, trainer, ace, veteran or champion-class</strong>.</p>\n\n  <p>Then they build their team to suit, members and power both. Every leader has a roster\nbuilt from the Pokémon they've used across the series, not just one game's party, and they\npick from it: a rookie meets a couple of their lighter Pokémon, a veteran meets their best.\nTheir levels aren't fixed either. They're set from yours, so their ace is always a little\nstronger than your strongest, and they never bring fewer Pokémon than you do. Turn up at Brock\nwith a strong team and Brock is strong too.</p>\n\n  <p>It's a challenge, not a wall. Across thousands of simulated battles at every tier, a\nchallenger wins about four times in ten, with good tactics doing the rest. Come back the\nsame day with the same team and you'll meet the same leader team, so a loss teaches you\nsomething.</p>\n\n  <h2>What they say</h2>\n\n  <p>The leader tells you what they've made of you before a ball is thrown. Every leader has\ntheir own lines, written for this, and the middle of their speech depends on your tier.\nBrock to a newcomer: <em>\"I'm Brock! A new trainer? Easy does it for now.\"</em> Brock to someone\nwith a reputation: <em>\"So you're the one. No holding back!\"</em></p>\n\n</section>\n\n<div style=\"display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:12px;max-width:760px;margin:0 auto;\">\n  <figure class=\"pixel\" style=\"margin:0;\"><img src=\"../assets/img/pokewalker/gym-brock-entrance.png\" width=\"720\" height=\"720\" alt=\"Brock's entrance: his portrait over a rocky arena, his name on a ribbon with a ROOKIE tag, and the speech box reading I'M BROCK! A NEW TRAINER? EASY DOES IT FOR NOW.\" /><figcaption>Brock has you down as a rookie.</figcaption></figure>\n  <figure class=\"pixel\" style=\"margin:0;\"><img src=\"../assets/img/pokewalker/gym-blaine-entrance.png\" width=\"720\" height=\"720\" alt=\"Blaine's entrance over lava: his name with a ROOKIE tag and the speech box beginning HAH! I'M BLAINE! QUESTION ONE: NEW? A LOW FLAME FOR...\" /><figcaption>Blaine, in the volcano.</figcaption></figure>\n  <figure class=\"pixel\" style=\"margin:0;\"><img src=\"../assets/img/pokewalker/gym-morty-entrance.png\" width=\"720\" height=\"720\" alt=\"Morty's entrance in a dark shrine: I SAW YOU COMING. A FAINT AURA. NEW? I'LL DIM THE...\" /><figcaption>Morty saw you coming.</figcaption></figure>\n</div>\n\n<section class=\"prose\">\n\n  <h2>The entrance</h2>\n\n  <p>Each gym battle opens with the camera circling the arena while the gym's name types out.\nThen the leader's portrait sweeps in over their element (Blaine through flame, Morty out of\nfog, Surge in a crackle of lightning) with their name on a ribbon and your tier on a gold\ntab beside it. Their speech types out underneath. BOOT or a tap skips ahead.</p>\n\n  <p>After that it's the battle you already know: the match card, the throws, the lanes, the\nclashes on critical hits and knockouts into the wall. Only now the wall is a crater rim, or\na lighthouse rail, or a garden hedge.</p>\n\n</section>\n\n<div style=\"display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:12px;max-width:760px;margin:0 auto;\">\n  <figure class=\"pixel\" style=\"margin:0;\"><img src=\"../assets/img/pokewalker/gym-blaine-title.png\" width=\"720\" height=\"720\" alt=\"The title card over Blaine's arena: GYM LEADER and the gym's name in large orange letters over lava.\" /><figcaption>The title card.</figcaption></figure>\n  <figure class=\"pixel\" style=\"margin:0;\"><img src=\"../assets/img/pokewalker/gym-volcano-battle.png\" width=\"720\" height=\"720\" alt=\"A battle in Blaine's volcano arena: Charizard hits Growlithe for -11, DOUBLE and CRITICAL HIT, with lava behind.\" /><figcaption>A critical hit in the crater.</figcaption></figure>\n  <figure class=\"pixel\" style=\"margin:0;\"><img src=\"../assets/img/pokewalker/gym-volcano-badge.png\" width=\"720\" height=\"720\" alt=\"The badge screen: the Volcano Badge, a flame, on a blue burst of rays, with Blaine's closing line I'M BURNED OUT! CORRECT! THE VOLCANO...\" /><figcaption>The Volcano Badge.</figcaption></figure>\n</div>\n\n<section class=\"prose\">\n\n  <h2>The badges</h2>\n\n  <p>Win, and the badge flips in on a burst of light, lands with a ring, catches the light, and\nthe leader says their piece. Each of the sixteen is drawn large for that moment, with metal\nshading and a glint that comes round every couple of seconds, and small for your trainer\ncard, where the ones you haven't earned wait as grey shapes.</p>\n\n</section>\n\n<figure class=\"pixel\" style=\"margin-inline:auto;max-width:560px;\">\n  <img src=\"../assets/img/pokewalker/gym-badges.png\" width=\"1024\" height=\"1124\" alt=\"All sixteen badges drawn large on a dark background, four rows of four in challenge order: Kanto's grey Boulder, water-drop Cascade, sun Thunder, flower Rainbow, pink heart Soul, gold Marsh ring, flame Volcano and leaf Earth, then Johto's Zephyr wings, ladybird Hive, gold Plain, ghost Fog, fist Storm, steel Mineral, ice star Glacier and dragon Rising, with the sixteen small versions in a row beneath.\" />\n  <figcaption>The sixteen badges, large and small. Original drawings.</figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <h2>How it's built, and how it grows</h2>\n\n  <p>Gyms are data, so they can change without rewriting anything:</p>\n\n  <ul>\n    <li><strong>The ladder</strong> is one table: steps and team size for each place in the order. Retuning it is\nediting a row.</li>\n    <li><strong>Each leader</strong> is a roster, a set of tiers, some lines and a stage. Adding a leader, or a\nrematch with a stronger roster, is a new entry rather than new code.</li>\n    <li><strong>The balance</strong> is measured, not guessed. A test plays thousands of battles at every tier\nand fails if the challenger's chances drift outside a band, so a change to the battle\nengine can't quietly make a gym unbeatable.</li>\n    <li><strong>The arenas</strong> all share one field and swap the world around it, which is why a new\nstage is cheap.</li>\n  </ul>\n\n  <p>What comes next builds on those pieces: rematches once you hold all sixteen, an Elite Four\nafter them, and the portal taking part, so a badge you win shows on your trainer profile\nand the leaderboards know who's been through which gym.</p>\n\n</section>\n",
      "date_published": "2026-11-14T18:57:38+00:00"
    },
    {
      "id": "https://alchemy86.github.io/devlog/posts/the-stadium-shakes.html",
      "url": "https://alchemy86.github.io/devlog/posts/the-stadium-shakes.html",
      "title": "The stadium shakes",
      "summary": "Battles on the Pokewalker now play out in a League stadium on its round screen: the match card, your Pokémon's own ball thrown at the camera, three lanes of dodging, beam struggles on critical hits, knockouts that crack the wall, and gym leaders for badges.",
      "content_html": "<section class=\"prose\">\n\n  <h2>A whole match</h2>\n\n  <p>This is a full three-on-three, start to finish: the match card, the send-outs, a beam\nstruggle on a critical hit, knockouts into the wall, a switch, and the winner's board. The\nengine played every turn; nothing here is scripted.</p>\n\n</section>\n\n<figure style=\"margin-inline:auto;\">\n  <video controls=\"\" preload=\"metadata\" poster=\"../assets/img/pokewalker/battle-match-poster.png\" width=\"480\" height=\"480\">\n    <source src=\"../assets/video/pokewalker/battle-match.mp4\" type=\"video/mp4\" />\n  </video>\n  <figcaption>AARON against SILVER at Indigo Plateau. Bulbasaur, Charizard and Marill at level 12.</figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <h2>Starting one</h2>\n\n  <p>On the walker, open the ball and swipe to the games ring. The crossed swords are BATTLE.\nFrom there:</p>\n\n  <ul>\n    <li><strong>Quick battle</strong> puts you against a rival whose team is matched to yours.</li>\n    <li><strong>Gym challenge</strong> puts you against the next leader you haven't beaten.</li>\n    <li><strong>Online</strong> is greyed out until the portal's live battles reach the walker.</li>\n  </ul>\n\n  <p>BOOT starts the highlighted one and PWR backs out. PWR in the middle of a battle walks away\nfrom it, and walking away records nothing.</p>\n\n</section>\n\n<div style=\"display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:12px;max-width:760px;margin:0 auto;\">\n  <figure class=\"pixel\" style=\"margin:0;\"><img src=\"../assets/img/pokewalker/battle-menu.png\" width=\"720\" height=\"720\" alt=\"The walker's battle menu: QUICK BATTLE vs RIVAL highlighted, GYM CHALLENGE vs BUGSY with a badge silhouette, ONLINE greyed out, and BADGES 1/16 at the bottom.\" /><figcaption>The battle menu.</figcaption></figure>\n  <figure class=\"pixel\" style=\"margin:0;\"><img src=\"../assets/img/pokewalker/battle-vs-card.png\" width=\"720\" height=\"720\" alt=\"The match card: the screen split diagonally red and green, AARON's portrait on the left, SILVER's on the right, a VS badge between them, INDIGO PLATEAU across the top and three bars under each trainer.\" /><figcaption>The match card. One bar per Pokémon.</figcaption></figure>\n  <figure class=\"pixel\" style=\"margin:0;\"><img src=\"../assets/img/pokewalker/battle-throw.png\" width=\"720\" height=\"720\" alt=\"A close-up of a Poké Ball tumbling towards the camera over blue speed lines.\" /><figcaption>Each Pokémon comes out of its own ball.</figcaption></figure>\n</div>\n\n<section class=\"prose\">\n\n  <h2>The match card and the send-out</h2>\n\n  <p>A match opens on a card in the style of the anime's League scoreboard: both trainers'\nportraits, the event, and a bar for every Pokémon on each side. It comes back between\nknockouts with that Pokémon's bar gone dark, so you always know the score.</p>\n\n  <p>Then the balls come out. Each Pokémon is thrown in whatever ball it lives in on the walker,\nspinning at the camera, before it lands on its mark, pops open with the cartridge's own\nsound and the Pokémon forms out of the light. Switching one out is the classic red beam:\nit hits, the Pokémon becomes a ball of red light, and the light goes home.</p>\n\n  <h2>How a turn works</h2>\n\n  <p>The field is a clay stadium with three lanes: left, centre and right. Every turn, both\nsides choose a move and, in secret, where to stand: jump left, hold, or jump right. Both\nare revealed at once.</p>\n\n  <ul>\n    <li>Stand in the lane an attack is aimed at, or jump into it, and it lands for <strong>double</strong>.</li>\n    <li>Jump one lane clear and it may still clip you for a <strong>graze</strong>, about half.</li>\n    <li>Get two lanes clear and it <strong>misses</strong>.</li>\n  </ul>\n\n  <p>Some moves cover more than one lane, and some always find their target. A fast Pokémon can\nclear two lanes in one leap, a heavy one shrugs off grazes, and jumping costs a little\npower. Under all of that sit Generation 1's real rules: stats, types, critical hits, status\nand switching. A trainer's tactics decide how their Pokémon play it: how aggressive, which\nway they like to dodge, whether they punish a Pokémon that keeps standing still.</p>\n\n</section>\n\n<div style=\"display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:12px;max-width:760px;margin:0 auto;\">\n  <figure class=\"pixel\" style=\"margin:0;\"><img src=\"../assets/img/pokewalker/battle-turn.png\" width=\"720\" height=\"720\" alt=\"Turn 1 in the stadium: Vulpix far away near the far end, Bulbasaur close to the camera, thin health lines around the edge of the round screen.\" /><figcaption>Turn one. Health runs round the rim.</figcaption></figure>\n  <figure class=\"pixel\" style=\"margin:0;\"><img src=\"../assets/img/pokewalker/battle-clash.png\" width=\"720\" height=\"720\" alt=\"Side-on view of Charizard and Vulpix firing beams that meet in a white burst of energy in the middle of the field.\" /><figcaption>A clash: both beams meet in the middle.</figcaption></figure>\n  <figure class=\"pixel\" style=\"margin:0;\"><img src=\"../assets/img/pokewalker/battle-crit.png\" width=\"720\" height=\"720\" alt=\"Vulpix knocked back with a damage number of minus 11 and the words DOUBLE and CRITICAL HIT.\" /><figcaption>The critical side wins the struggle.</figcaption></figure>\n</div>\n\n<section class=\"prose\">\n\n  <h2>When the camera swings side-on</h2>\n\n  <p>Most turns play one attack after the other from behind your Pokémon's shoulder. A\n<strong>critical hit</strong> changes that. When a turn has a critical hit and both Pokémon get to\nattack, the camera swings round side-on and they fire at the same moment. The two attacks\nmeet in the middle of the field as a crackling ball of energy, and it shoves back and forth\nwhile the stadium shakes and the crowd's cameras flash. Then the side that landed the\ncritical hit drives through.</p>\n\n  <p>It stays honest. The engine already decided the turn, so if the other side struck first,\nits hit lands first; if the critical hit knocks it out before it can act, its beam is\nswallowed and never lands at all.</p>\n\n  <h2>Knockouts</h2>\n\n  <p>A knockout gets weight of its own. The last frames slow down, and the Pokémon is thrown\nback across the field into the stadium wall. It shrinks as it flies, because it really is\ntravelling away from you, and where it hits, the wall cracks. The crack stays there for the\nrest of the battle, so a long match leaves its marks on the stadium.</p>\n\n</section>\n\n<div style=\"display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:12px;max-width:760px;margin:0 auto;\">\n  <figure class=\"pixel\" style=\"margin:0;\"><img src=\"../assets/img/pokewalker/battle-wall-slam.png\" width=\"720\" height=\"720\" alt=\"Bulbasaur small against the far wall of the stadium with cracks spreading from where it hit.\" /><figcaption>Thrown into the far wall.</figcaption></figure>\n  <figure class=\"pixel\" style=\"margin:0;\"><img src=\"../assets/img/pokewalker/battle-recall.png\" width=\"720\" height=\"720\" alt=\"A thin red beam running across the field to recall a Pokémon.\" /><figcaption>The recall beam.</figcaption></figure>\n  <figure class=\"pixel\" style=\"margin:0;\"><img src=\"../assets/img/pokewalker/battle-winner.png\" width=\"720\" height=\"720\" alt=\"The winner board: WINNER in orange letters with an arrow pointing at AARON's portrait, three bars beside it and CONGRATULATIONS below.\" /><figcaption>The winner's board.</figcaption></figure>\n</div>\n\n<section class=\"prose\">\n\n  <h2>How it's won</h2>\n\n  <p>A battle ends when one side has no Pokémon left standing. When a Pokémon faints and its\ntrainer still has others, the scoreboard shows, and the next one is thrown in. When the\nlast one goes down, there is no scoreboard: the loser fades away at the wall, the winner\nstands in the stadium, and the WINNER board closes over them. A battle that somehow runs to\ntwo hundred turns is a draw.</p>\n\n  <p>Every result goes on your trainer card as wins, losses and draws, kept separately for\nlocal, online and ranked battles, along with your best winning streak.</p>\n\n  <h2>Gym leaders</h2>\n\n  <p>The gym challenge runs through all sixteen leaders region by region: the eight from Kanto,\nBrock to Blue, then the eight from Johto, Falkner to Clair. Each brings Pokémon from their\nown roster and their own portrait on the match card. The battles run on Generation 1's\nrules, so a Johto Pokémon fights with the stats of a close Kanto stand-in (Steelix as Onix,\nMiltank as Tauros) while still looking and sounding like itself, and moves that only exist\nin Gold are left out.</p>\n\n  <p>A leader's team isn't fixed. They size up the team you've brought and pick their Pokémon\nand levels to stay a little stronger than you, whatever your level. There's a <a href=\"the-leader-reads-your-team.html\">whole post\non how they do it</a>.</p>\n\n  <p>Beat one and the badge is yours. It grows in on a burst of light (\"FALKNER GAVE YOU THE\nZEPHYR BADGE, 1/16\"), lands on a badges page of your trainer card, and the menu offers the\nnext leader.</p>\n\n</section>\n\n<div style=\"display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:12px;max-width:520px;margin:0 auto;\">\n  <figure class=\"pixel\" style=\"margin:0;\"><img src=\"../assets/img/pokewalker/battle-badge.png\" width=\"720\" height=\"720\" alt=\"The badge screen: FALKNER GAVE YOU THE ZEPHYR BADGE, 1/16, with the badge on a burst of blue rays.\" /><figcaption>The Zephyr Badge.</figcaption></figure>\n  <figure class=\"pixel\" style=\"margin:0;\"><img src=\"../assets/img/pokewalker/battle-badges-page.png\" width=\"720\" height=\"720\" alt=\"The trainer card's BADGES 1/16 page: sixteen badge shapes, the Zephyr Badge in colour and the rest as grey silhouettes.\" /><figcaption>Fifteen to go.</figcaption></figure>\n</div>\n\n<section class=\"prose\">\n\n  <h2>Sound</h2>\n\n  <p>Battles play Pokémon Blue's battle themes on the walker's emulated Game Boy sound chip:\nTrainer Battle for a quick battle, Gym Leader for a gym, Final Battle for Blue, and the\nvictory tune once if you win. Every move plays the sound effect Pokémon Gold gives it,\nrecorded from the game's own sound engine, and each Pokémon cries when it comes out and\nwhen it falls.</p>\n\n  <h2>Still to come</h2>\n\n  <p>Battles are in the walker's software and run in its desktop simulator and the browser\nbuild; they haven't been played on the board itself yet. Battles against other people's\nwalkers are next, through the portal: challenge a friend and the server plays both sides'\ntactics, or battle live and choose each turn yourself, with every match kept as a replay a\nfew hundred bytes long.</p>\n\n</section>\n",
      "date_published": "2026-11-14T18:06:06+00:00"
    },
    {
      "id": "https://alchemy86.github.io/devlog/posts/dodge-left-take-double.html",
      "url": "https://alchemy86.github.io/devlog/posts/dodge-left-take-double.html",
      "title": "Dodge left, take double",
      "summary": "The Pokewalker is getting battles, with one twist on Generation 1: three lanes and a secret stance every turn. Jump the wrong way and an attack lands for double. Twenty thousand simulated matches say no tactic runs away with it.",
      "content_html": "<section class=\"prose\">\n\n  <h2>Battles with a mind game in them</h2>\n\n  <p>Underneath, these are Generation 1 battles: the same stats, damage formula, type chart,\ncritical hits, status conditions and switching as Red and Blue, for all 151 Pokémon and\n165 moves.</p>\n\n  <p>On top sits a field with three lanes. Each turn, both sides choose a move and a stance at\nthe same time, and neither sees the other's choice until both are locked in. Then everyone\nlands, and the attacks fly.</p>\n\n</section>\n\n<figure style=\"margin-inline:auto;\">\n  <img src=\"../assets/img/pokewalker/battle-lanes.png\" width=\"1540\" height=\"506\" alt=\"Four diagrams of three lanes with an attack fired up the centre lane. A defender holding in the centre takes double damage. A defender leaping from the left into the centre takes double. A defender jumping from centre to right takes a graze. A defender leaping from left all the way to right is missed.\" />\n  <figcaption>An aimed attack down the centre lane, and four ways the defender can meet it.</figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <h2>What an attack does</h2>\n\n  <p>Moves come in shapes:</p>\n\n  <ul>\n    <li><strong>Aimed</strong> moves, like Thunderbolt, Flamethrower or Body Slam, go down one lane. A Pokémon in that lane\ntakes double. One lane over, it is usually grazed for about half. Two lanes over, it is\nmissed.</li>\n    <li><strong>Wide</strong> moves, like Surf, Earthquake and Razor Leaf, hit their lane and the lanes beside it, at three quarters of their power.</li>\n    <li><strong>Centre bursts</strong>, like Fire Blast and Pin Missile, hit their lane in full and always catch\nthe lanes beside them with the edge.</li>\n    <li><strong>Follow</strong> moves, like Swift and Psychic, track the target and never miss, but never land\nfor double either.</li>\n  </ul>\n\n  <p>The Pokémon matter as much as the lanes. A fast one sometimes clears two lanes in a single\nleap. A heavy one takes less from a graze. And a Pokémon that jumps attacks off balance, at\nthree quarters of its power. Without that cost, the evasive trainer won 58% of matches and\neveryone would have played that way.</p>\n\n  <h2>A turn, as the engine writes it</h2>\n\n  <p>This is turn 11 of a match between an aggressive trainer and an evasive one. Snorlax has\njust come in for red. Alakazam is nearly untouched.</p>\n\n  <div class=\"language-plaintext highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>-- turn 11\nSNORLAX jumps left -&gt; centre\nALAKAZAM jumps left -&gt; centre\nSNORLAX uses DOUBLE-EDGE (Aimed) at the centre lane\n  -&gt; DOUBLE on ALAKAZAM: 130 damage, 0 HP left\n  SNORLAX Recoil 32 (203 left)\n  ALAKAZAM faints!\n</code></pre></div>  </div>\n\n  <p>Alakazam read Snorlax as coming left and jumped to meet it, straight into the lane the\nDouble-Edge was aimed at. Full health to fainted in one strike, even with Snorlax swinging\noff balance.</p>\n\n  <p>Two turns later the same trick failed. Blastoise, on 17 HP, jumped clear and Snorlax's\nDouble-Edge went through an empty lane:</p>\n\n  <div class=\"language-plaintext highlighter-rouge\"><div class=\"highlight\"><pre class=\"highlight\"><code>-- turn 13\nSNORLAX holds the right lane\nBLASTOISE jumps centre -&gt; left\nSNORLAX uses DOUBLE-EDGE (Aimed) at the right lane\n  -&gt; MISS on BLASTOISE: 0 damage, 17 HP left [dodged clean]\n</code></pre></div>  </div>\n\n</section>\n\n<figure style=\"margin-inline:auto;\">\n  <img src=\"../assets/img/pokewalker/battle-timeline.png\" width=\"1210\" height=\"506\" alt=\"A step chart of each Pokémon's HP across 14 turns. Red's Charizard, Jolteon and Snorlax against blue's Blastoise, Venusaur and Alakazam. Double-damage strikes are marked 2x, and a clean miss on turn 13 is marked. Snorlax finishes Blastoise on turn 14.\" />\n  <figcaption>The whole match. Every drop marked 2x is someone standing in, or jumping into, the wrong lane.</figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <h2>Twenty thousand matches</h2>\n\n  <p>A twist like this is easy to get wrong. If dodging is too strong, nobody ever stands still.\nIf it is too weak, nobody bothers to move. So the engine plays itself: three against three\nat level 50, every combination of tactics against every other, with the teams swapped each\ntime so only the tactics decide.</p>\n\n  <p>Across 402,810 strikes, a little over a quarter land for double and about the same share\nare grazes. A Pokémon that holds still is hit far more often. One that jumps is missed far\nmore often, and still takes double a quarter of the time, because the other trainer guessed\nwhere it would land.</p>\n\n</section>\n\n<figure style=\"margin-inline:auto;\">\n  <img src=\"../assets/img/pokewalker/battle-outcomes.png\" width=\"1210\" height=\"462\" alt=\"Stacked bars of outcomes. Every strike: 17% miss, 28% graze, 26% hit, 28% double. When the defender held: 9% miss, 24% graze, 34% hit, 33% double. When the defender jumped: 22% miss, 31% graze, 21% hit, 25% double.\" />\n  <figcaption>Holding still gets you hit. Jumping gets you missed, unless they read you.</figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <h2>Football Manager, not Street Fighter</h2>\n\n  <p>You don't press buttons every turn. You set tactics, the way a manager sets team\ninstructions:</p>\n\n  <ul>\n    <li><strong>Temper</strong>: aggressive, balanced or evasive.</li>\n    <li><strong>Dodge bias</strong>: favour left, favour right, or mix it up.</li>\n    <li><strong>Reading</strong>: punish a Pokémon that keeps holding, or predict where it will jump.</li>\n    <li><strong>Switching</strong>: pull a Pokémon out at low HP or a bad type matchup.</li>\n    <li><strong>Move priority</strong>, per Pokémon.</li>\n  </ul>\n\n  <p>The AI plays from those, using only what both trainers can see, including how each\nPokémon has jumped so far. In a live match you are on the touchline with a handful of\ndirect orders to spend. In an automated one, you watch the replay afterwards and change\nyour instructions.</p>\n\n  <p>The test that matters is whether any setting wins on its own. None does. The best complete\nset of tactics wins 55.1% of its matches and the worst 43.3%. A match lasts about 16 turns.</p>\n\n</section>\n\n<figure style=\"margin-inline:auto;\">\n  <img src=\"../assets/img/pokewalker/battle-tactics.png\" width=\"1210\" height=\"594\" alt=\"Win rates for each tactic setting, against tactics that differ on that setting. Temper: aggressive 49.3%, balanced 52.3%, evasive 48.4%. Dodge bias: left 50.5%, right 49.2%, mixed 50.3%. Reading: punish holders 52.3%, predict 51.6%, mixed 46.0%. Switching: never 50.2%, at 30% HP or bad type 49.8%.\" />\n  <figcaption>Every setting lands within a few points of even. Guessing at random (“mixed” reading) is the one that costs you.</figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <h2>The same battle everywhere</h2>\n\n  <p>The engine is a small Rust library with no floating point and no dependencies. The same\ncode will run on the walker, in a browser and on the server that hosts online battles, and\na given seed plus both trainers' choices produce the same result on every one of them. Five\nhundred simulated battles came out byte for byte identical on a PC and in WebAssembly.</p>\n\n  <p>That means a battle never has to be sent as video. A whole match is the random seed, the two\nteams and each turn's choices: about a hundred bytes. The walker downloads that and replays\nthe fight itself.</p>\n\n  <h2>Still to come</h2>\n\n  <p>Nine Generation 1 moves aren't in yet: Counter, Bide, Mimic, Metronome, Mirror Move,\nTransform, Conversion, Disable and Substitute. Wrap and its kin do their damage but don't\ntrap yet. When a Pokémon faints, the next one in line comes in.</p>\n\n  <p>Next is the part you see: the two Pokémon facing each other on the walker's round screen,\njumping between lanes, with the real move animations aimed at wherever the target ends up.</p>\n\n</section>\n",
      "date_published": "2026-11-14T14:00:49+00:00"
    },
    {
      "id": "https://alchemy86.github.io/devlog/posts/the-moonwalk-was-a-bug.html",
      "url": "https://alchemy86.github.io/devlog/posts/the-moonwalk-was-a-bug.html",
      "title": "The moonwalk was a bug",
      "summary": "The Pokewalker is growing a virtual pet: one of your Pokémon in the Gold bedroom, fed, rubbed and visited by its friends. Then a friend turned up mid-dance and the pet walked off backwards. It stayed.",
      "content_html": "<section class=\"prose\">\n\n  <h2>A pet, not a pedometer</h2>\n\n  <p>The Pokewalker already counts steps and turns them into Watts. Pet mode gives that walking\nsomewhere to go. You pick a Pokémon from your team and it moves into a room: it gets hungry,\nsleepy and bored, it shows a ! on the walking screen when it wants you, and it cheers up when\nyou rub it, feed it a berry or play with it. Leave it alone and it gets sad, nothing worse,\nand one Oran Berry and a rub put it right.</p>\n\n  <p>The room is the real bedroom from Pokémon Gold, pulled off the cartridge: the PC, the radio,\nthe TV, the bookshelf, the stairs and the floor the game itself says you can walk on. The\ncamera follows the pet, so the room scrolls round it as it goes.</p>\n\n  <p>The pet is its HeartGold follower sprite, the little walking Pokémon that trails behind you\nin that game. Every species from 1 to 251 has one, four directions with a step in each, and\nthe shiny colours sit right beside the normal ones. Ask for any Pokémon and it walks in as\nitself.</p>\n\n  <h2>Friends drop in</h2>\n\n  <p>The rest of the team visit. A happy pet gets a caller every few hours: another of your\nPokémon walks in from the side of the room, the pet makes space, and the two bounce at each\nother face to face for a while before the visitor heads off again. Both get a heart for it.\nEach visitor is its own follower sprite, so whoever is on your team is who turns up, and they\ntake turns.</p>\n\n</section>\n\n<figure class=\"pixel\" style=\"margin-inline:auto;\">\n  <img src=\"../assets/img/pokewalker/pet-mode-visit.png\" width=\"627\" height=\"631\" alt=\"The pet software's simulator window: Bulbasaur in front of the PC and radio in the Gold bedroom, with Charizard come to visit beside it, four hearts full along the top.\" />\n  <figcaption>Charizard calls on Bulbasaur. Four hearts: a visit is good for both of them.</figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <h2>The radio</h2>\n\n  <p>Tap the radio on the desk and the pet walks over, switches it on and dances: turning left,\nfront and right on the half beat, hopping on the beat, notes rising off the radio. The music\nis the walker's own Radio, Gen 1's songs played on an emulated Game Boy sound chip, so it is\nwhatever you have starred, or Cycling, Surfing Pikachu and a few others if you have not.</p>\n\n  <p>When the music comes on, another member of the team drops in to dance too.</p>\n\n  <h2>The bug</h2>\n\n  <p>That last part came later. The first version had visits on their own timer: a friend walked\nin, the two bounced at each other for eight seconds, the friend walked out. And while a\nfriend was there, the pet was held facing it, because that is what playing together looks\nlike.</p>\n\n  <p>Then a friend arrived halfway through a song. The song ended, the pet went back to wandering,\nand the visit was still holding it facing its friend. So it walked away from Charizard while\nlooking straight at him.</p>\n\n</section>\n\n<figure class=\"pixel\" style=\"margin-inline:auto;\">\n  <img src=\"../assets/img/pokewalker/pet-mode-accidental-moonwalk.gif\" width=\"412\" height=\"412\" alt=\"Bulbasaur in the Gold bedroom: it wanders, is rubbed and fed, dances at the radio, Charizard drops in, and near the end Bulbasaur slides away from Charizard while still facing him.\" />\n  <figcaption>The original. Near the end, Bulbasaur leaves Charizard without turning round.</figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <h2>Now it is the ending</h2>\n\n  <p>It read as a moonwalk, and a moonwalk at the end of a dance is better than anything planned.\nSo it is planned now.</p>\n\n  <p>A friend who comes for the radio stays for the whole song. When the music stops the pet\nmoonwalks two cells away from it, at half pace, still facing it, legs going. Only once it has\nfinished does the friend walk off. With nobody visiting it moonwalks anyway, as an encore.</p>\n\n</section>\n\n<figure class=\"pixel\" style=\"margin-inline:auto;\">\n  <img src=\"../assets/img/pokewalker/pet-mode-peace-out.gif\" width=\"412\" height=\"412\" alt=\"Misdreavus switches the radio on and dances, Caterpie wriggles in and dances with her, and when the song ends Misdreavus moonwalks away still facing Caterpie, who then leaves.\" />\n  <figcaption>Misdreavus and Caterpie. Song ends, Misdreavus peaces out, Caterpie goes home.</figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <h2>What comes next</h2>\n\n  <ul>\n    <li><strong>Putting it on the board.</strong> It builds for the device; it has not run there yet. The\nboard's own real-time clock will let a pet catch up on the hours the walker was off.</li>\n    <li><strong>Spending Watts.</strong> A department store selling berries and the Gen 2 bedroom decorations:\ndolls, big dolls, carpets, plants, posters, consoles. Mom will buy some on her own when\nyour savings pass a milestone, as she did in Gold.</li>\n    <li><strong>Looking after it properly.</strong> Poison and paralysis from neglect with their own cure\nberries, grooming, and Pokérus, which turns up about once in three hundred days and doubles\nfriendship while it lasts.</li>\n    <li><strong>Eggs and evolution.</strong> Eggs that hatch by steps, the way they did in the games, and\nfriendship evolutions on Gen 2's own conditions.</li>\n  </ul>\n\n</section>\n",
      "date_published": "2026-11-13T00:00:00+00:00"
    },
    {
      "id": "https://alchemy86.github.io/devlog/posts/the-infrared-had-to-go.html",
      "url": "https://alchemy86.github.io/devlog/posts/the-infrared-had-to-go.html",
      "title": "The infrared had to go",
      "summary": "The Pokéwalker talked to a DS over infrared. This one plugs into a Game Boy with a link cable instead — a 74LVC2G17 where the IrDA transceiver used to be, inside a machined steel Poké Ball. The shell is drawn, weighed and checked against the real board, and the check currently fails.",
      "content_html": "<section class=\"prose\">\n\n  <h2>A Game Boy link is six pins and almost no parts</h2>\n\n  <p>The IrDA sheet is gone — the Vishay TFBS4711 and everything hanging off it. What replaced it\nis a 74LVC2G17 dual Schmitt buffer and five resistors.</p>\n\n  <p>Two of the six EXT pins are driven by the console at 5 V TTL, and those go through the buffer\nto get down to 3.3 V. Its inputs are 5 V tolerant at a 3.3 V supply, so there is no divider\nand no bidirectional shifter. The leg going the other way needs nothing at all: TTL's input\nthreshold is 2.0 V, so the device's 3.3 V output drives the console directly.</p>\n\n  <p>The device is the clock <strong>slave</strong>. A Game Boy link has no chip select, which is why this is a\njob for the RP2350's PIO rather than its PL022 — the hardware SPI's slave mode wants a select\nline to stay byte-aligned, and there isn't one.</p>\n\n  <figure class=\"narrow\" style=\"max-width:none;\">\n  <img src=\"../assets/img/pokewalker/gblink-sheet.png\" width=\"1600\" height=\"1131\" alt=\"The Game Boy link schematic sheet: connector J5 breaking out six EXT pins, a 74LVC2G17 dual Schmitt buffer, series and pull resistors, and five test points.\" />\n  <figcaption>The whole interface. Five of the six pins are used; P14 is a no-connect.</figcaption>\n</figure>\n\n  <p>Nothing in it is Gen-1 specific. The sheet carries SPI Mode 3 bytes and encodes no byte\ncounts, so a Gen 2 trade is a firmware problem, not a board respin.</p>\n\n  <h2>The connector is a row of pads, because nothing else fits</h2>\n\n  <p><code class=\"language-plaintext highlighter-rouge\">J5</code> is a new footprint rather than a part off a shelf: a 1×6 row of 1.27 mm solder pads. The\nlargest free rectangle on the back copper near the MCU measures 6.25 × 6.25 mm, and the\nsmallest 6-way JST SH needs 9.8 × 5.2 mm. The only place a real connector fits is the far end\nof the board, beside the USB-C and the power management.</p>\n\n  <p>Pads keep every connector option open, and they are what bring-up on a breadboard wants\nanyway. Five test points sit on SCK, SI, SO, ground and the link's own 5 V — this interface\nhas never seen a console, so it is instrumented rather than trusted.</p>\n\n  <p>The placement came from a measured free-space map of the back copper, not from eyeballing it.\nThat board outline is a rounded Pokéwalker shape with three screw-hole cutouts in it, two of\nthem sitting right inside the band where the parts had to go, and KiCad's own board-polygon\ncall does not treat a cutout as off-board. A search that does not exclude them will happily\nput a footprint in a hole.</p>\n\n  <h2>The Poké Ball look is paint, and it has to be</h2>\n\n  <p>The shell is two machined halves split at the ball's own band, with the belt clip cut into the\nback — the arrangement of the real device, whose clip lives on a swappable back cover.</p>\n\n  <figure class=\"narrow\">\n  <img src=\"../assets/img/pokewalker/shell-pokeball-face.png\" width=\"1400\" height=\"1400\" alt=\"The shell face-on: a full circle with a black band straight across the middle, red above, white below, and the screen centred on the band like the ball's button.\" />\n  <figcaption>Face-on, the icon reads. The silhouette measures 1138 × 1136 px — a true circle to 0.2%.</figcaption>\n</figure>\n\n  <p>That picture cost an afternoon of looking for a camera angle before the geometry settled it.\nA Poké Ball icon is a sphere seen level with its own equator. This part is a ⌀70 mm disc\n19 mm thick, so the same level camera renders a 69.5 × 19 mm lens. There is no elevation that\nturns a disc into a ball, and the only view whose silhouette is a true circle is straight at\nthe face — where the real band is edge-on at the rim and invisible.</p>\n\n  <p>So the stripe across the face is paint. The band round the equator is real: a 3.9 mm sunken\nrecess with a chamfered shoulder each side and the parting line down the centre of it,\n0.6 mm deep at its deepest out of a 1.2 mm wall. Red above and white below is a render\nchoice; no finish decision has been made.</p>\n\n  <figure class=\"narrow\">\n  <img src=\"../assets/img/pokewalker/shell-pokeball-top.png\" width=\"1600\" height=\"1200\" alt=\"The shell from a raised three-quarter angle: a domed red front with the black band arcing across the lower silhouette and a sliver of white behind it.\" />\n  <figcaption>From the angle a die-cast ball gets photographed at. The white back barely shows, and that is the model being honest: the dome stands 14 mm above the split line and the back only 5 mm.</figcaption>\n</figure>\n\n  <p>It is not a half-and-half ball and it cannot be while it is a Pokéwalker. Red covers about\nthree-quarters of the object's height because that is the real device's proportion. Making it\nread 50/50 is a form-factor decision, not a paint one.</p>\n\n  <h2>Boring the screen pocket flattens the dome</h2>\n\n  <p>The bezel has to be constant thickness over the window, so the outer surface is machined flat\nout to the bezel radius — on ⌀70, a flat 44 mm across, sitting 5.02 mm below where the sphere\nwould have been. A fifth of the front is a disc. That is exactly why it looks faceted next to\na real Pokéwalker.</p>\n\n  <p>The real device does not solve this in the housing either. It puts a clear cover over the\nfront and lets that carry the curve the screen cannot. So does this one.</p>\n\n  <figure class=\"narrow\" style=\"max-width:none;\">\n  <img src=\"../assets/img/pokewalker/shell-lens-compare.png\" width=\"2254\" height=\"1340\" alt=\"Four renders in a two-by-two grid. The left column is the shell without the cover, the right column with it fitted; the top row is edge-on, where the bare front shows a flat facet over the screen and the covered one a clear dome standing proud of it, and the bottom row is the same pair from three-quarters.\" />\n  <figcaption>Left, the machined flat. Right, the cover that puts the apex back where the sphere had it.</figcaption>\n</figure>\n\n  <p>It is the tightest thing in the model. Measured from the screen centre, the window's chamfered\nmouth ends at r=17.2 mm and the nearest button's mouth begins at r=18.47 mm. Everything the\ncover needs on the face — flange, land, slip fit — lives in that 1.27 mm.</p>\n\n  <p>The check for it is an intersection rather than an assertion: the target builds the shared\nvolume of cover and shell and fails unless it comes out with zero facets. Forcing the fit\n0.5 mm the wrong way makes it report 1280 facets, which is how you know the check has teeth.</p>\n\n  <h2>The plug cannot reach the socket</h2>\n\n  <p><code class=\"language-plaintext highlighter-rouge\">make check</code> fails on the ⌀70 configuration, and it is right to.</p>\n\n  <p>The board's minimum enclosing circle is ⌀50.50 mm. The bore it sits in is ⌀67.6. That leaves\nthe USB-C receptacle's mouth <strong>7.27 mm</strong> inside the shell wall, and a USB-C plug seats its\novermould against the case with about 6.5 mm of nose — all of which is needed inside the\nreceptacle, not crossing seven millimetres of fresh air. No chamfer or funnel fixes it.</p>\n\n  <p>Three things do, and they are all board decisions: make the board reach the wall, move the\nconnector out on a flex or riser, or give up on USB-C and accept a recessed pogo or magnetic\ncharger. It is a tighter trade than it looks. In a ⌀60 shell the bore is ⌀57.6 at the split\nplane but the dome has already narrowed to ⌀54.9 a millimetre above it, so a board big enough\nto reach the wall has to sit at or below the split line — which eats the space underneath that\nthe receptacle needs, and the back has to get deeper to pay for it.</p>\n\n  <p>And ⌀48, the size that gets quoted as the answer, does not satisfy it either: in a ⌀60 shell a\n⌀48 board still leaves a 4.8 mm gap and the plug still cannot reach.</p>\n\n  <h2>The clip will go slack</h2>\n\n  <p>Report and instinct both say a printed 316L clip takes a set and stops gripping. Machining it\ndoes not help, because that is not a process problem — 316L is not a spring material in any\nprocess. As drawn, the clip grips when new and goes soft.</p>\n\n  <p>Three ways out, none of which change the geometry: machine the back from 17-7 PH in condition\nA and age-harden it afterwards, machine it in titanium TC4, or redraw the clip as a hook that\nbarely flexes and lets geometry do the retention. The back is a separate piece held by three\nscrews, so trying a second one in a different material is cheap.</p>\n\n  <h2>What the numbers are</h2>\n\n  <p>Both configurations export and both were weighed from the real solid volumes at 7.98 g/cm³,\nnot estimated from a wall thickness: <strong>86.1 g</strong> for ⌀70 (front 36.4, back 49.7) and <strong>62.7 g</strong>\nfor ⌀60. Both are a long way under the 143 g a solid ⌀70 ball suggests, because a flat-backed\nPokéwalker is a long way from a sphere. The clear cover adds about 1.3 g in acrylic.</p>\n\n  <p>Every dimension that could plausibly change is a named parameter, and the model asserts its\nown rules while it renders — that the band leaves at least 0.5 mm of wall, that the screw\nheads stay on the flat, that the bosses clear the board. The board geometry is not typed in\neither: the outline, the mounting holes, the buttons and every footprint's courtyard are\npulled straight out of the <code class=\"language-plaintext highlighter-rouge\">.kicad_pcb</code>, so a board change and a stale shell cannot coexist\nquietly.</p>\n\n  <h2>What is not done</h2>\n\n  <p>The link nets are placed but not routed, and hand-routing is the only option. Freerouting was\ntried properly on this board and is not usable: it plateaus at 62 unrouted and 417 violations,\nits fanout stage rewrites the whole board rather than the nets you asked for, and importing\nits result takes the board from 981 tracks to 203 — it wipes routing on seventy nets that were\nalready fine. It also routes straight through the screw-hole cutouts, because the export\nformat does not carry them as keepouts.</p>\n\n  <p>Beyond that: the interface has never been run against a console, the ball size is still open,\nand a keyed bayonet joint that makes the front half swappable — Poké Ball, Great Ball, Ultra\nBall, and a Team Rocket ball that is a fan design rather than canon — is drawn and parked\nuntil the side buttons are settled, because the lugs have to miss the ports.</p>\n\n</section>\n",
      "date_published": "2026-09-16T00:00:00+00:00"
    },
    {
      "id": "https://alchemy86.github.io/devlog/posts/the-leaderboard-that-does-not-exist.html",
      "url": "https://alchemy86.github.io/devlog/posts/the-leaderboard-that-does-not-exist.html",
      "title": "The leaderboard that does not exist",
      "summary": "Nobody ranks Game Boy emulators by speed, because a frame rate belongs to a machine and a render mode rather than to an emulator. Four projects measure it anyway, all measuring something different. Timing mGBA, SameBoy and PyBoy on one core here first cost us three of our own numbers — and then showed the speed ordering is the accuracy ordering upside down.",
      "content_html": "<section class=\"prose\">\n\n  <h2>Two of our own numbers flattered us and one was never measured</h2>\n\n  <p><strong>We had never timed mGBA.</strong> Every sentence this project had written about native emulator\nspeed came from reading rather than from a clock. The expectation put to the work was that C\nemulators run at thousands of frames a second where PyBoy manages hundreds, and that PyBoy is\nfast only for something with Python bindings. That expectation had been setting the target, and\nit did not survive being run.</p>\n\n  <p><strong>Our bench had no sound chip in it, and theirs cannot take one out.</strong> With no audio player\ninstalled, our APU's per-cycle entry point returns immediately — the headless figure we had\nbeen publishing was a machine with no APU at all. mGBA and SameBoy emulate the audio hardware\nwhether or not anyone is listening, and neither offers a switch. So every earlier row compared\ntwo different machines, and the difference went our way.</p>\n\n  <p><strong>17% of the PyBoy figure was our own harness.</strong> We were calling <code class=\"language-plaintext highlighter-rouge\">tick(1, False)</code> 7,168 times\nfrom Python and timing the loop, while our side runs its frame loop in Rust with no binding in\nthe way. The same work in a single <code class=\"language-plaintext highlighter-rouge\">tick(7168, False)</code> is 0.0157 ms a frame rather than\n0.0190. The missing 0.0033 was the cost of asking, in Python, 7,168 times — and we had been\ncharging it to PyBoy.</p>\n\n  <p>Two of the three moved against us. The one that had never been measured at all went the other\nway.</p>\n\n  <h2>What a row has to satisfy before it means anything</h2>\n\n  <ul>\n    <li>One box, one P-core, pinned. Thread CPU time, not wall clock. This machine is eight P-cores\nat 5.3 GHz beside twelve E-cores at 4.6, and an unpinned process moves the answer by 15% or\nmore between runs of the identical binary.</li>\n    <li>One cartridge, one frame count. Pokémon Blue, 7,168 frames from reset — 120 emulated\nseconds — on every side.</li>\n    <li>Every row interleaved with every other row in the same session, and the load average stated.\nQuote the load average or do not quote the number: at load 16 every figure below reads about\na third slower, in the same order and the same ratios.</li>\n    <li>Every side built with its own release flags. SameBoy under its own <code class=\"language-plaintext highlighter-rouge\">CONF=release</code>, ours at\n<code class=\"language-plaintext highlighter-rouge\">opt-level = 3</code> with fat LTO, PyBoy as the published Cython wheel.</li>\n    <li>The sound chip present on both sides, or absent from both.</li>\n  </ul>\n\n  <p>And then the part that is easy to miss: <strong>pair the picture engines, or you have measured a PPU\nrather than an emulator.</strong> mGBA's Game Boy PPU is event-scheduled at mode boundaries, which is\narchitecturally our <code class=\"language-plaintext highlighter-rouge\">standard</code>. SameBoy's is a per-dot pixel FIFO, which is our <code class=\"language-plaintext highlighter-rouge\">identical</code>.\nCrossing them produces a number with nothing inside it.</p>\n\n  <h2>The result</h2>\n\n  <p>One P-core, interleaved, load 1.9, pixels and audio on for every native row.</p>\n\n</section>\n\n<div class=\"table-wrap\">\n  <table>\n    <thead>\n      <tr>\n        <th>Emulator</th>\n        <th class=\"num\">ms / frame</th>\n        <th class=\"num\">&times; real time</th>\n        <th>PPU granularity</th>\n      </tr>\n    </thead>\n    <tbody>\n      <tr><td><strong>TerminalGB <code>standard</code></strong></td><td class=\"num\"><strong>0.0666</strong></td><td class=\"num\">251&times;</td><td>whole scanline</td></tr>\n      <tr><td>mGBA, render on</td><td class=\"num\">0.0819</td><td class=\"num\">204&times;</td><td>event-scheduled modes</td></tr>\n      <tr><td><strong>TerminalGB <code>identical</code></strong> (the default)</td><td class=\"num\"><strong>0.2126</strong></td><td class=\"num\">79&times;</td><td>per-dot FIFO</td></tr>\n      <tr><td>SameBoy, render on</td><td class=\"num\">0.4084</td><td class=\"num\">41&times;</td><td>per-dot FIFO</td></tr>\n    </tbody>\n  </table>\n</div>\n\n<section class=\"prose\">\n\n  <p>We are 1.23× faster than mGBA and 1.92× faster than SameBoy, each against the engine of its\nown granularity. PyBoy does not belong in that table — it has a switch for its sound chip and\nwe have no chip to switch — so it gets its own pairing, APU-free on both sides: <strong>PyBoy\n0.0156 against our 0.0297, which is 1.90× ahead of us.</strong></p>\n\n  <p>mGBA with its renderer off reads 0.0555, and that row is not in the table because it is a\ndifferent machine from the one SameBoy and our <code class=\"language-plaintext highlighter-rouge\">identical</code> are running.</p>\n\n  <h2>The ordering is the accuracy ordering, upside down</h2>\n\n  <p>The\n<a href=\"https://github.com/gbdev/GBEmulatorShootout\">GB Emulator Shootout</a> publishes 24 DMG rows from\nthe Mealybug Tearoom suite, which is the test set that separates the two or three most exact\nPPUs in the world from everyone else. SameBoy takes 15 of them. bgb takes 2. PyBoy takes 0.\nEleven are pixel-exact here on the per-dot engine, against the same DMG references; on the whole\n79-row suite that engine takes 29 where our fast engine takes 3.</p>\n\n  <p>So the slowest emulator measured above is the most exact one in the field, and the fastest is\nthe one that scores nothing on the suite that matters most. PyBoy is the fastest Game Boy\nemulator on this machine, and what it buys that with is not being cycle-accurate.</p>\n\n  <p>The cleanest reading of the trade is not between projects at all. It is between our own two\npicture engines, where the binary, the cartridge, the core and the frame count are the same and\nonly the PPU changes: 0.0666 against 0.2126, a factor of 3.2, and 3 Mealybug rows against 29.\nTwenty rows of the Shootout's 264-row manifest sit in that gap too — 223 on the fast engine\nagainst 243 on the exact one, which is 5th of 19 on the board as it stood in June, behind\nSameBoy's 253 and ahead of mGBA's 150.</p>\n\n  <p>Nothing about the cost of exactness needed a second project to demonstrate. What the second\nproject settled is that there is no faster native emulator here to catch, which is what everyone\nhad assumed there was. There is a design to catch, and its price is already on the books.</p>\n\n</section>\n\n<div class=\"pullquote\">\n  <p>There is no faster native emulator here to catch. There is a design.</p>\n</div>\n\n<section class=\"prose\">\n\n  <h2>RosettaBoy is measuring something else, and the something else is real</h2>\n\n  <p><a href=\"https://github.com/shish/rosettaboy\">RosettaBoy</a> is one emulator design implemented in twenty\nlanguage-and-build combinations, and its table is the cleanest measurement of language overhead\nanyone has for this workload. Its own run, <code class=\"language-plaintext highlighter-rouge\">--headless --silent</code> on an M1 MacBook Pro:</p>\n\n</section>\n\n<div class=\"table-wrap\">\n  <table>\n    <thead>\n      <tr><th>Implementation</th><th class=\"num\">fps</th><th>Implementation</th><th class=\"num\">fps</th></tr>\n    </thead>\n    <tbody>\n      <tr><td>Nim, LTO</td><td class=\"num\">1,643</td><td>Go</td><td class=\"num\">503</td></tr>\n      <tr><td>Rust, LTO</td><td class=\"num\">1,603</td><td>Cython</td><td class=\"num\">361</td></tr>\n      <tr><td>C++, LTO</td><td class=\"num\">1,506</td><td>Python, Mypyc</td><td class=\"num\">79</td></tr>\n      <tr><td>C, LTO</td><td class=\"num\">1,505</td><td>PHP</td><td class=\"num\">26</td></tr>\n      <tr><td>Zig</td><td class=\"num\">884</td><td>Python</td><td class=\"num\">16</td></tr>\n    </tbody>\n  </table>\n</div>\n\n<section class=\"prose\">\n\n  <p>Read across a row and you learn something true and useful: the same program, written the same\nway, costs a hundred times more in CPython than in Rust, and a little over three times more in\nGo than in Nim. That is the question RosettaBoy asks and it answers it well.</p>\n\n  <p>Read a single cell as a ceiling and you learn nothing. Its Rust row is 1,603 fps; the same\nconfiguration here — headless, silent — is 33,700, and the M1 it ran on is not twenty-one times\nslower than this box. Its Python row is 16 fps and PyBoy on this box is 64,100, four thousand\ntimes apart; its Cython row of 361 is RosettaBoy's own Cython port and not PyBoy's core either.\nNeither difference is language. RosettaBoy's author says plainly that readability,\nconsistency and idiomatic style come before hardware accuracy, and that the implementations are\nnot in sync with one another; a shared simple design is the whole point of the exercise and it\nis not what any shipping emulator is. The valid comparison in that table is between its own\nrows.</p>\n\n  <h2>GameRoy priced the accuracy tax, and the price is not the JIT</h2>\n\n  <p><a href=\"https://github.com/Rodrigodd/gameroy\">GameRoy</a> is a high-accuracy Game Boy emulator in Rust\nthat grew a JIT, and\n<a href=\"https://rodrigodd.github.io/2023/09/02/gameroy-jit.html\">its author wrote the result up</a>\nhonestly enough to be worth more than the code. The compiled code is around 4× the raw speed of\nhis own interpreter and takes 30–40% off the execution time of a real game — real, and short of\nwhat a JIT usually promises. What eats it is exactly the constraint we live under: a\ncycle-accurate emulator has to update its peripherals before every memory access, so a\ncompiled block cannot simply run. His answer is to predict whether an interrupt lands inside\nthe block and fall back to the interpreter when it does, which keeps the accuracy and keeps an\ninterpreter in the build forever.</p>\n\n  <p>The line worth quoting is the one about somebody else: BGB is more than twice as fast as\nGameRoy, and he attributes the difference to frameskip rather than to code generation. A\nthroughput figure that includes frameskip and one that does not are two different\nmeasurements wearing the same unit.</p>\n\n  <h2>mGBA wrote the technique down in 2017</h2>\n\n  <p>endrift's <a href=\"https://mgba.io/2017/04/30/emulation-accuracy/\"><em>Emulation Accuracy, Speed, and Optimization</em></a>\nis the clearest statement of why cycle accuracy is expensive, and it is not about arithmetic:\nhardware does every step of a cycle at once, software cannot, so it swaps between them, and the\nswapping is the cost. mGBA's Game Boy core divides instruction emulation into per-clock-cycle\ntasks and emulates the other hardware between them — then batches those operations instead of\nrunning them one at a time, splitting a batch whenever two things genuinely interact.</p>\n\n  <p>That is our own idle batch, arrived at independently and from the other end, and the same idea\nhas now paid twice here. The halted CPU's batch used to stop at every PPU mode boundary, three\nor four a scanline, when what a halted CPU can observe of the PPU is two bits of <code class=\"language-plaintext highlighter-rouge\">IF</code> and\nnothing else. Asking whether a STAT interrupt could actually be taken at that edge took the\nbatch from 38 M-cycles to 505. The identical argument, applied inside the per-dot engine, is\nworth 29.3% of a default-mode frame on its own — and a cartridge that arms a STAT source keeps\nthe old behaviour exactly, which is why no accuracy row moved. The right number of peripheral\nsteps to take is the number a program can tell you took, and both projects got there by asking\nwhat the program can see.</p>\n\n  <h2>What is left of the gap, with a number rather than an argument</h2>\n\n  <p>Profiled at the 0.0382 accurate frame this round started from, <code class=\"language-plaintext highlighter-rouge\">bus_tick</code> was 28.7% of it and\nthe MMU's per-cycle entry point another 16.1%. That 44.8% is precisely the per-access peripheral\nwork PyBoy does not do, and taking it off lands where you would expect: 0.0211, PyBoy's\nneighbourhood once its own horizon bookkeeping is allowed for. Closing it in the default mode\nmeans giving up what Blargg's <code class=\"language-plaintext highlighter-rouge\">mem_timing</code> and fourteen Mooneye instruction-timing ROMs\nmeasure.</p>\n\n  <p>In speed mode the shape changes and what is left is the interpreter: roughly 55 host cycles an\nemulated instruction against PyBoy's 33. A build with every accuracy liberty in the ledger\napplied at once — OAM DMA bus conflicts, the work-RAM address override, the OAM-page hook, the\nlink cable, the per-access APU and PPU hooks, the interrupt folds — measures 3.1% better and is\nstill 1.60× behind. Beating 0.0156 from there is a different execution model, not another pass.</p>\n\n  <p>Which is a better place to stand than the one we were standing in a week ago, where the target\nwas a number somebody measured on their laptop. The full record, every negative result\nincluded, is on the <a href=\"../terminalgb-performance.html\">throughput page</a>, and the accuracy those\nmilliseconds buy is on the <a href=\"../projects/terminalgb.html\">TerminalGB project page</a>.</p>\n\n</section>\n",
      "date_published": "2026-09-09T00:00:00+00:00"
    },
    {
      "id": "https://alchemy86.github.io/devlog/posts/the-trainer-who-saw-him-black-out.html",
      "url": "https://alchemy86.github.io/devlog/posts/the-trainer-who-saw-him-black-out.html",
      "title": "The trainer who saw him black out",
      "summary": "One seed walks into Viridian Forest and is put straight into a trainer battle on the doorway tile, nine decisions after crossing the boundary, by a Bug Catcher forty-five tiles away. The cartridge had been holding that fight open since the last time he fainted.",
      "content_html": "<section class=\"prose\">\n\n  <p class=\"chips\" style=\"margin-bottom:20px;\">\n  <span class=\"chip on\">measured</span>\n  <span class=\"chip\">inferred</span>\n</p>\n\n  <p><strong>Measured</strong> is a byte read out of a saved state or a field read out of a run record.\n<strong>Inferred</strong> is reasoning from one of those to something we did not read. Prior community\nwork is named where it appears.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>Nine decisions</h2>\n\n  <p>He crosses from the Viridian Forest south gate into the forest on decision 4094 and lands on\ntile (17,47). The emulator's own map data lists that tile as one of four exits back to the\ngate he just came through — it is the doorway.</p>\n\n  <p>He never leaves it. Two decisions later a text box opens: <em>Hey, wait up! What's the hurry?</em>\nFour decisions after that the screen goes to the battle wipe, and on decision 4103 he is in\na fight. Between crossing the boundary and the fight he pressed <code class=\"language-plaintext highlighter-rouge\">up</code>, <code class=\"language-plaintext highlighter-rouge\">a</code>, <code class=\"language-plaintext highlighter-rouge\">up</code>, <code class=\"language-plaintext highlighter-rouge\">b</code>, <code class=\"language-plaintext highlighter-rouge\">up</code>,\n<code class=\"language-plaintext highlighter-rouge\">b</code>, <code class=\"language-plaintext highlighter-rouge\">up</code>, <code class=\"language-plaintext highlighter-rouge\">a</code>, <code class=\"language-plaintext highlighter-rouge\">a</code>, and his coordinates did not change once.</p>\n\n</section>\n\n<figure class=\"clip-auto\" style=\"max-width:640px;margin-inline:auto;\">\n  <video muted=\"\" loop=\"\" autoplay=\"\" playsinline=\"\" preload=\"metadata\" poster=\"../assets/img/agentgb/forest-doorway-poster.png\" width=\"636\" height=\"568\">\n    <source src=\"../assets/video/agentgb/forest-doorway-battle.mp4\" type=\"video/mp4\" />\n  </video>\n  <img class=\"clip-poster\" src=\"../assets/img/agentgb/forest-doorway-poster.png\" width=\"636\" height=\"568\" alt=\"A Game Boy screen: the player stands at the bottom edge of Viridian Forest among the trees, and a text box reads 'Hey, wait up! What's the hurry?'\" />\n  <figcaption>\n    Eleven seconds cut from the swarm film, cropped to the first of its six tiles, at the\n    film's own eightfold speed and otherwise untouched. Route 2, the gate, the forest, and\n    the fight — then he wins it, and it starts again.\n  </figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <div class=\"fig-pair\" style=\"max-width:none;\">\n  <figure class=\"pixel\">\n    <p class=\"cap\">Decision 4096&ndash;4098 &middot; <span class=\"accent\">on the doorway tile</span></p>\n    <img src=\"../assets/img/agentgb/forest-doorway-hail.png\" width=\"318\" height=\"284\" alt=\"Viridian Forest at its southern edge. The player sprite stands one tile inside the map; a text box reads 'Hey, wait up! What's the hu'.\" />\n    <figcaption>Two decisions after crossing the boundary. He has not moved.</figcaption>\n  </figure>\n  <figure class=\"pixel\">\n    <p class=\"cap\">Decision 4108 &middot; <span class=\"accent\">the fight</span></p>\n    <img src=\"../assets/img/agentgb/forest-doorway-catcher.png\" width=\"318\" height=\"284\" alt=\"A Game Boy trainer-battle intro: the player's back sprite on the left, a Bug Catcher with a net on the right, and a text box beginning 'BUG CATCHER wa'.\" />\n    <figcaption>A trainer battle, on the tile the map uses as its own front door.</figcaption>\n  </figure>\n</div>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>It is a trainer, and the cartridge says so</h2>\n\n  <p><span class=\"chip on\">measured</span>\nRead at decision 4110: <code class=\"language-plaintext highlighter-rouge\">wIsInBattle</code> (<code class=\"language-plaintext highlighter-rouge\">$D057</code>) is <strong>2</strong>, which the atlas names as a trainer\nbattle and not a wild one. <code class=\"language-plaintext highlighter-rouge\">wCurOpponent</code> (<code class=\"language-plaintext highlighter-rouge\">$D059</code>) is <strong>202</strong> — at or above 200 it is a\ntrainer class plus that offset, so class 2, a Bug Catcher. <code class=\"language-plaintext highlighter-rouge\">wTrainerClass</code> (<code class=\"language-plaintext highlighter-rouge\">$D031</code>) is <strong>2</strong>\nand agrees. The opponent is a WEEDLE at level 9.</p>\n\n  <p>There is nowhere for a Bug Catcher to be standing. The doorway tile is an exit; the fight\nstarted with the player one tile inside a map he had entered nine decisions earlier, and\nforty-five tiles — sixteen columns and twenty-nine rows — from where he last fainted.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>The same tile, one visit earlier</h2>\n\n  <p>This was his third visit to Viridian Forest. On the second he crossed the same boundary and\nstood on the same tile (17,47) for two decisions and walked on. Nothing happened. His first\nbattle of that visit came ninety-eight decisions later, at (6,12), and it was wild.</p>\n\n  <p>Between the second visit and the third, one thing happened to him.</p>\n\n  <div class=\"wide-table\">\n<table>\n  <thead>\n    <tr>\n      <th>Decision</th>\n      <th>Map</th>\n      <th class=\"num\">Tile</th>\n      <th>Screen</th>\n      <th><code>$D057</code></th>\n      <th><code>$D059</code></th>\n      <th><code>$D618</code></th>\n      <th>Pressed</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr><td>3303</td><td>Viridian Forest</td><td class=\"num\">(17,47)</td><td>walking in, visit two</td><td>none</td><td class=\"num\">0</td><td class=\"num\">0</td><td><code>a</code></td></tr>\n    <tr><td>3634</td><td>Viridian Forest</td><td class=\"num\">(1,18)</td><td>a wild CATERPIE, level 4</td><td>wild</td><td class=\"num\">0</td><td class=\"num\">0</td><td><code>up</code></td></tr>\n    <tr><td>3708</td><td>Viridian Forest</td><td class=\"num\">(1,18)</td><td><em>BLUE blacked out!</em></td><td>wild</td><td class=\"num\">0</td><td class=\"num\">0</td><td><code>a</code></td></tr>\n    <tr><td><strong>3709</strong></td><td>Viridian Forest</td><td class=\"num\">(1,18)</td><td>the warp</td><td><strong>blacked-out</strong></td><td class=\"num\">0</td><td class=\"num\">0</td><td><code>a</code></td></tr>\n    <tr><td><strong>3711</strong></td><td>Viridian Forest</td><td class=\"num\">(1,18)</td><td>the warp</td><td>blacked-out</td><td class=\"num\">0</td><td class=\"num\"><strong>1</strong></td><td><code>a</code></td></tr>\n    <tr><td>3714</td><td>Viridian City</td><td class=\"num\">(23,26)</td><td>awake, 24/24</td><td>none</td><td class=\"num\">0</td><td class=\"num\">1</td><td><code>a</code></td></tr>\n    <tr><td>4088</td><td>Forest south gate</td><td class=\"num\">(5,6)</td><td>walking back up</td><td>none</td><td class=\"num\">0</td><td class=\"num\">1</td><td><code>up</code></td></tr>\n    <tr><td>4094</td><td>Viridian Forest</td><td class=\"num\">(17,47)</td><td>crossing in, visit three</td><td>none</td><td class=\"num\">0</td><td class=\"num\">1</td><td><code>up</code></td></tr>\n    <tr><td>4098</td><td>Viridian Forest</td><td class=\"num\">(17,47)</td><td><em>Hey, wait up!</em></td><td>none</td><td class=\"num\">0</td><td class=\"num\">1</td><td><code>up</code></td></tr>\n    <tr><td><strong>4110</strong></td><td>Viridian Forest</td><td class=\"num\">(17,47)</td><td>WEEDLE Lv9</td><td><strong>trainer</strong></td><td class=\"num\"><strong>202</strong></td><td class=\"num\"><strong>4</strong></td><td><code>a</code></td></tr>\n  </tbody>\n</table>\n</div>\n\n  <p><span class=\"chip on\">measured</span>\n<code class=\"language-plaintext highlighter-rouge\">$D618</code> is <code class=\"language-plaintext highlighter-rouge\">wViridianForestCurScript</code> — how far through Viridian Forest's own map script the\ngame is. It is 0 on both earlier visits, goes to 1 two decisions into the blackout, stays 1\nthrough the warp, the Pokémon Center, Route 2 and the gate, and is still 1 when he steps back\nonto the doorway tile. The battle takes it to 4.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>What survived the blackout</h2>\n\n  <p>Comparing the same eight bytes at four moments answers which of them carries the fight across.</p>\n\n  <div class=\"wide-table\">\n<table>\n  <thead>\n    <tr>\n      <th>Address &middot; symbol</th>\n      <th class=\"num\">Walking, d3630</th>\n      <th class=\"num\">Blacked out, d3709</th>\n      <th class=\"num\">Awake, d3718</th>\n      <th class=\"num\">At the door, d4098</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr><td><code>$CD60</code> <code>wMiscFlags</code> bit 0</td><td class=\"num\">0</td><td class=\"num\"><strong>1</strong></td><td class=\"num\">0</td><td class=\"num\">0</td></tr>\n    <tr><td><code>$CD2D</code> <code>wEngagedTrainerClass</code></td><td class=\"num\">6</td><td class=\"num\"><strong>202</strong></td><td class=\"num\">202</td><td class=\"num\">7</td></tr>\n    <tr><td><code>$CD2E</code> <code>wEngagedTrainerSet</code></td><td class=\"num\">7</td><td class=\"num\"><strong>3</strong></td><td class=\"num\">3</td><td class=\"num\">7</td></tr>\n    <tr><td><code>$CF13</code> <code>wSpriteIndex</code></td><td class=\"num\">0</td><td class=\"num\"><strong>4</strong></td><td class=\"num\">4</td><td class=\"num\"><strong>4</strong></td></tr>\n    <tr><td><code>$CC55</code> <code>wTrainerHeaderFlagBit</code></td><td class=\"num\">0</td><td class=\"num\"><strong>4</strong></td><td class=\"num\">4</td><td class=\"num\"><strong>4</strong></td></tr>\n    <tr><td><code>$DA30</code> <code>wTrainerHeaderPtr</code></td><td class=\"num\">$6651</td><td class=\"num\"><strong>$5A51</strong></td><td class=\"num\">$5A51</td><td class=\"num\"><strong>$5A51</strong></td></tr>\n    <tr><td><code>$D618</code> <code>wViridianForestCurScript</code></td><td class=\"num\">0</td><td class=\"num\">0 &rarr; <strong>1</strong></td><td class=\"num\">1</td><td class=\"num\"><strong>1</strong></td></tr>\n    <tr><td><code>$DA39</code> <code>wCurMapScript</code></td><td class=\"num\">0</td><td class=\"num\">0 &rarr; <strong>1</strong></td><td class=\"num\">1</td><td class=\"num\"><strong>1</strong></td></tr>\n  </tbody>\n</table>\n</div>\n\n  <p><span class=\"chip on\">measured</span>\nEvery one of those bytes is 0, or holds an unrelated value, on the last decision of the wild\nbattle. They are set on the next one — the decision the cartridge writes <code class=\"language-plaintext highlighter-rouge\">$FF</code> into\n<code class=\"language-plaintext highlighter-rouge\">wIsInBattle</code>, which the atlas names as <em>the player blacked out</em> and which is not a battle.\n<code class=\"language-plaintext highlighter-rouge\">wEngagedTrainerClass</code> reads 202 and <code class=\"language-plaintext highlighter-rouge\">wEngagedTrainerSet</code> reads 3 — a Bug Catcher, roster\nthree — and the fight that started at the door was a Bug Catcher leading a level 9 WEEDLE.</p>\n\n  <p><code class=\"language-plaintext highlighter-rouge\">$CD60</code> bit 0 — the flag that says a trainer has spotted the player — is cleared by the time\nhe is awake in Viridian City. So is the engaged-trainer pair, by the time he reaches the\ngate. What is not cleared is the map's own script index, and the sprite slot and header\npointer that tell that script which trainer it is about to run. Viridian Forest's script is\nleft at step 1, which is <em>a trainer is waiting to fight you</em>, and the map runs it the moment\nthe map is loaded again.</p>\n\n  <div class=\"pullquote\">\n  <p>The blackout put him a town away and healed his party. It did not put the forest back\n  the way it found it.</p>\n</div>\n\n  <p><span class=\"chip\">inferred</span>\nSprite slot 4's stored map coordinates read 22 and 6, and under Gen 1's four-tile bias on\nsprite coordinates that is tile (2,18) — one step east of (1,18), where he fainted. That is\nconsistent with a Bug Catcher standing directly beside him at the moment the wild encounter\nstarted, and it is an inference from the sprite table, not a reading of the trainer's tile.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>This one has a name, and it is not ours</h2>\n\n  <p>The community found and documented this long before we walked into it. It is the <strong>trainer\nescape glitch</strong>, also called trainer-Fly, and the variant we hit is the death-warp one:\nfaint to a wild encounter inside a trainer's field of vision, and, in the Glitch City Wiki's\nwords, <em>\"the trainer will notice the player on that frame, advancing the meta-map script ID\njust before the player warps away.\"</em> Returning to the map gives an instant encounter. The\nsame wiki page names <code class=\"language-plaintext highlighter-rouge\">$CD60</code> bit 0 as the byte set when a trainer spots the player, which is\nthe byte our own read agrees with.</p>\n\n  <p>Its wider significance is theirs too. Escaping a trainer battle rather than blacking out is\nwhat makes the glitch dangerous: it leaves an encounter staged from stale battle memory, and\nthat is the foundation of the Mew glitch and a component of the arbitrary-code-execution\nroutes speedrunners use in Red and Blue.</p>\n\n  <p>What we hit is the tame end of it. Our student blacked out rather than escaping, so the\ncartridge staged a real Bug Catcher with a real WEEDLE rather than a corrupted one, and\nnothing about the run afterwards is corrupt. The interesting part is not the mechanism.\nIt is that an agent nobody told about any of this walked into it on its own, and that we can\nput a rate on it.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>How often it happens to us</h2>\n\n  <p>Every trainer battle a run starts in Viridian Forest is logged with the tile the player was\nstanding on. Across every recorded episode we hold, those tiles cluster hard.</p>\n\n  <div class=\"wide-table\">\n<table>\n  <thead>\n    <tr><th class=\"num\">Tile</th><th class=\"num\">Trainer battles started there</th><th>What it is</th></tr>\n  </thead>\n  <tbody>\n    <tr><td class=\"num\">(1,18)</td><td class=\"num\">672</td><td>Inside the forest</td></tr>\n    <tr><td class=\"num\">(26,33)</td><td class=\"num\">157</td><td>Inside the forest</td></tr>\n    <tr><td class=\"num\">(27,33)</td><td class=\"num\">28</td><td>Inside the forest</td></tr>\n    <tr><td class=\"num\"><strong>(17,47)</strong></td><td class=\"num\"><strong>21</strong></td><td><strong>A south-gate exit tile</strong></td></tr>\n    <tr><td class=\"num\">(26,19)</td><td class=\"num\">7</td><td>Inside the forest</td></tr>\n    <tr><td class=\"num\">(27,30)</td><td class=\"num\">3</td><td>Inside the forest</td></tr>\n    <tr><td class=\"num\">(2,19)</td><td class=\"num\">3</td><td>Inside the forest</td></tr>\n  </tbody>\n</table>\n</div>\n\n  <p>One row is a tile you cannot fight anybody on. Following it out:</p>\n\n  <div class=\"wide-table\">\n<table>\n  <thead>\n    <tr><th>Population</th><th class=\"num\">Runs</th><th class=\"num\">Doorway battle</th><th class=\"num\">Finished the chain</th></tr>\n  </thead>\n  <tbody>\n    <tr><td>Every recorded episode we hold</td><td class=\"num\">44,706</td><td class=\"num\">—</td><td class=\"num\">—</td></tr>\n    <tr><td>&hellip; of those, runs whose goal set can detect it</td><td class=\"num\">11,927</td><td class=\"num\"><strong>32</strong></td><td class=\"num\"><strong>0</strong></td></tr>\n    <tr><td>&hellip; spanning distinct seeds</td><td class=\"num\">625</td><td class=\"num\"><strong>1</strong></td><td class=\"num\">—</td></tr>\n    <tr><td>The six paired sweeps of 7 Sep 2026</td><td class=\"num\">390</td><td class=\"num\">6</td><td class=\"num\">0</td></tr>\n  </tbody>\n</table>\n</div>\n\n  <p><span class=\"chip on\">measured</span>\nThirty-two recorded runs across five separate run roots start a trainer battle on a Viridian\nForest exit tile. Every one of the thirty-two is seed <strong>4200126</strong>. None of the thirty-two\nfinished the chain.</p>\n\n  <p>That seed has been re-run under six different goal configurations in one day, scoring\nbetween 91 and 96 whole chains out of 100 between them, and it failed in all six. Only one\nother seed in the hundred does that. Changing what the student believes about battle screens,\nabout items, about catching, does not touch this one, because none of it is about the\nstudent.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>What it cost him</h2>\n\n  <p>He won the forced battle on decision 4251. Three decisions later, on the same tile, <em>BUG\nCATCHER wants to fight!</em> again, and the same level 9 WEEDLE. That fight ran to 4377.</p>\n\n  <p>Then the run stops being a run.</p>\n\n  <div class=\"wide-table\">\n<table>\n  <thead>\n    <tr>\n      <th>Visit to Viridian Forest</th>\n      <th class=\"num\">Decisions inside</th>\n      <th class=\"num\">Distinct tiles</th>\n      <th class=\"num\">Furthest north</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr><td>One — decisions 2733&ndash;3086</td><td class=\"num\">353</td><td class=\"num\">111</td><td class=\"num\">row 3</td></tr>\n    <tr><td>Two — decisions 3302&ndash;3709</td><td class=\"num\">407</td><td class=\"num\">116</td><td class=\"num\">row 3</td></tr>\n    <tr><td><strong>Three — decisions 4094&ndash;8660</strong></td><td class=\"num\"><strong>4,566</strong></td><td class=\"num\"><strong>28</strong></td><td class=\"num\"><strong>row 35</strong></td></tr>\n  </tbody>\n</table>\n</div>\n\n  <p>The exit he needs is on row 0. On his first two visits he reached row 3, twice, having walked\nover a hundred distinct tiles each time. On the third he walked twenty-eight, never got above\nrow 35, entered no battle at all after the two at the door, pressed <code class=\"language-plaintext highlighter-rouge\">down</code> 2,358 times, and\nran out of budget at (16,38) with the gate goal still latched: the goal that walks him back\ntowards the door he came in through.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>What we cannot say from this recording</h2>\n\n  <ul class=\"gaps\">\n  <li>\n    <b>When the sight line actually fired.</b> Every trainer byte is clear on decision 3708,\n    the decision that prints <em>BLUE blacked out!</em>, and set on 3709. One decision is\n    thirty-two emulator frames, so this recording cannot separate <em>the trainer noticed him\n    as the wild battle began and the write happened later</em> from <em>the trainer noticed\n    him as the battle ended</em>. The community describes the first; we measured the write,\n    not the notice.\n  </li>\n  <li>\n    <b>Which trainer the second battle was.</b> No state was saved inside it. It was a Bug\n    Catcher with a level 9 WEEDLE, from the screen, and that is as far as our recording goes.\n  </li>\n  <li>\n    <b>How many other runs black out inside Viridian Forest.</b> Answering that needs\n    per-decision traces for episodes we only hold summaries of. The doorway signature above\n    is what the recorded data can carry on its own, and it is a lower bound: a run that hit\n    the same fault and then died before the goal fired would not appear in it.\n  </li>\n  <li>\n    <b><code>wTrainerNo</code> (<code>$D05D</code>) proves nothing here.</b> It reads 3 from\n    the first probe to the last and never changes, so its agreeing with roster three is a\n    coincidence, not evidence. The identity comes from <code>wEngagedTrainerSet</code>, which\n    changed.\n  </li>\n</ul>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>What it changes</h2>\n\n  <p>For the student: nothing to fix. He walked a legal route, took a legal encounter, lost it,\nand was warped away by the game's own rules. Everything after that was the cartridge running\na script it should have reset. There is no observation he could have made and no button he\ncould have pressed that would have avoided the second battle, because the fight was already\nstaged before the map was drawn.</p>\n\n  <p>For us it changes how one number should be read. Every recorded run of seed 4200126 that reaches the\ndoorway battle fails, thirty-two out of thirty-two, and each one has been counted as one more\nrun that got confused in the forest. It is not that. It is one run that met a\ndocumented fault in Pokémon Blue, and none of the six configurations tried on it so far makes\nany difference, because none of them is about the cartridge. A 96-out-of-100 with this seed\ninside it is really a 96 out of 99 plus one cartridge bug, and the honest way to report a\nsweep is to say which of its failures are the agent's.</p>\n\n  <p>It also raises the price of a blackout. The healing chamber added last week treats a faint as\na cost in decisions — you lose the walk back. It is not only that. Faint on the wrong tile\nand the map keeps a fight for you, and it will be waiting at the door.</p>\n\n</section>\n",
      "date_published": "2026-09-07T00:00:00+00:00"
    },
    {
      "id": "https://alchemy86.github.io/devlog/posts/the-trap-was-always-on-the-map.html",
      "url": "https://alchemy86.github.io/devlog/posts/the-trap-was-always-on-the-map.html",
      "title": "The trap was always on the map",
      "summary": "Collapsing the student into one compiled file did not break him. It changed which way he walked, and the new way went through a fault that had been sitting in the shared control flow all along.",
      "content_html": "<section class=\"prose\">\n\n  <h2>Ten cold boots, none of them finished</h2>\n\n  <p>The paired comparison was the ordinary kind: same weights, same sampling settings, same\nchain, ten cold boots each, one path against the other. The compiled artefact finished\n<strong>0 of 10</strong>. The flexible construction it was built to replace finished <strong>8 of 10</strong>.</p>\n\n  <p>On mGBA, three boots each: the old foreign driver <strong>2 of 3</strong>, the artefact <strong>0 of 3</strong>, all\nthree of them stranded at 20 or 21 of the chain's 25 links, in the same shop.</p>\n\n  <p>There is an obvious reading of those numbers and it was available immediately. One thing\nchanged, that thing is an ONNX export, ONNX exports are fiddly, file it as \"the compiled\ngraph is wrong\" and move on. That reading is wrong, and the only reason it did not get\nfiled is that somebody went and measured the actual frame the runs were dying on instead of\nreasoning about which component was newest.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>Nothing was retrained</h2>\n\n  <p>Worth stating plainly, because everything after it depends on it.</p>\n\n  <p>The collapse compiles the base network, every recogniser and adapter the running config\nneeds, and the control flow itself — the sticky chain's latch and successor walk, a\ntransient goal's scope and eligibility, a chamber's arm and disarm, a battle hold's\npatience counter — into one graph. <code class=\"language-plaintext highlighter-rouge\">src/agentgb/artifact_driver.py</code> is the only place\neither runner touches it: build the observation, hand it over with the previous decision's\nstate, take back the action and the next state. No latch logic left in the runners at all.</p>\n\n  <p>The weights file is untouched. Same sha256 before and after. It is a compile of what\nalready existed, not a rebuild of it, and the guard that proves it picks the same buttons\nruns a thousand paired decisions of synthetic noise across five seeds — three greedy, two\nsampled with the production confidence gate and decay — with zero disagreements, latch\nstate and held stage included.</p>\n\n  <p>So: two paths, provably identical on every decision anyone had checked, one of them\nwinning eight runs and the other winning none.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>New does not mean guilty</h2>\n\n  <p>The runs were all dying in the same place, so the frame they were dying on was the thing to\nlook at.</p>\n\n  <p><code class=\"language-plaintext highlighter-rouge\">battle-on-screen-recognizer</code> — the shared network that answers \"is a battle still\nhappening\" — reads <strong>0.608</strong> on an ordinary shop purchase-confirmation box. Not a near-tie\nagainst its threshold. A confident, wrong yes, on a screen with no battle anywhere in it.\nThe dialogue box in a shop confirmation is a black-bordered text box, and so is the one in\na fight.</p>\n\n  <p>That reading was taken by calling the real, native network directly on the real frame, with\nno ONNX runtime involved in the measurement at all. The compiled graph is not in the\npicture. The fault is in the shared control flow both paths run, and it was in there before\nthe collapse was written.</p>\n\n  <div class=\"pullquote\">\n  <p>The compiled version did not add a fault. It changed the route, and the new route went\n  through one.</p>\n</div>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>Two thresholds on one network, and the loose one is the one that gets fooled</h2>\n\n  <p>The battle wheel asks that recogniser two different questions with two different bars.</p>\n\n  <p>To <em>enter</em> a hold, the entry gate wants <strong>0.999</strong>. To <em>release</em> one, the end condition\nchecks the same network against <strong>0.5</strong>, holding while it stays above, with a release\npatience of 24 decisions. Both <code class=\"language-plaintext highlighter-rouge\">battle-hold-trainer</code> and <code class=\"language-plaintext highlighter-rouge\">battle-hold-wild</code> share that\ngate.</p>\n\n  <p>A phantom battle at 0.608 can never start a hold. It clears 0.5 comfortably, and 0.999 not\nat all. What it can do is keep a dead one alive.</p>\n\n  <p>A real rival fight around decision 201 leaves the trainer hold latched with its miss counter\nclimbing normally — 606, 608, and onward to 630 by decision 1092, far past a patience of 24.\nIt never expires, because every time the run walks back into a shop and reads a\nconfirmation box, the same shared gate says 0.608, the counter resets to zero, and the stale\nhold re-arms. The trainer battle's adapter — not the walking adapter the chain has long\nsince moved on to — keeps pressing through the shop's confirmation screens, buying one\nitem at a time until the wallet is empty and the chain stalls.</p>\n\n  <p>Every part of that is reachable by the old path too. It is one recogniser, one threshold\nand one counter, all of them shipped and certified long before this task started.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>A difference too small to fail a check, and large enough to change the route</h2>\n\n  <p>The graph is verified against a numpy reference that re-implements the same control flow,\nand the check it has to pass is a maximum absolute difference in the logits below <code class=\"language-plaintext highlighter-rouge\">1e-3</code>.\nIt passes. onnxruntime and native numpy do not compute a convolution to the last bit, and\nsub-<code class=\"language-plaintext highlighter-rouge\">0.001</code> is a reasonable place to draw the line.</p>\n\n  <p>It is also enough to flip a near-tied argmax, which was confirmed directly at decision 546\nof a real run: <code class=\"language-plaintext highlighter-rouge\">up</code> against <code class=\"language-plaintext highlighter-rouge\">right</code>, the pick depending on which backend did the arithmetic,\nwith no goal latched on either driver. No control-flow machinery active. Just the base\nnetwork, two backends, and a tie broken two different ways.</p>\n\n  <p>From there the trajectories are simply different runs. The artefact's route revisits the\nshop while that stale hold has not yet expired far more often than the flexible driver's\nroute does, on these ten seeds. Same map, different walk. Sharing the RNG stream between\nthe two drivers was tried and removes one source of divergence; the identical N=10\ncomparison with it enabled still returns 0/10, because the argmax flip is not an RNG\nquestion.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>A faithful copy is a measuring instrument</h2>\n\n  <p>The useful thing here is not the bug. It is what the pair of paths turned out to be good\nfor.</p>\n\n  <p>Two implementations that provably agree on every decision in isolation diverged completely\nin practice, and the divergence carried information. The synthetic checks could not have\nfound this, and it is clear why once you look at them: random noise never triggers a real\nbattle, and the graph's own verification forces a handful of degenerate frames, never a\nmulti-thousand-decision sequence with a real fight followed by a real shop visit. Neither\ncheck is weak. They answer a different question from \"safe to drive a long chain run\nwith\".</p>\n\n  <p>The 8-out-of-10 was the misleading number. Eighty per cent looks like a spread of ordinary\nbad luck, and it was concealing a specific trap that the winning route happened to miss\nmost of the time. It took a harmless numerical nudge — small enough to pass every\ntolerance the project sets — to make the trap show up ten times out of ten. A rate that\ngood can hide a fault this sharp, and the way it stopped hiding was a second\nimplementation walking a slightly different line through the same map.</p>\n\n  <p><code class=\"language-plaintext highlighter-rouge\">--use-artifact</code> is an explicit flag rather than the default because of that measurement.\nThe first design routed to the artefact automatically whenever the goal set and the policy\nmatched what it was compiled for. A plain run today is byte-for-byte what it was before\nany of this.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>What is still open</h2>\n\n  <p>The fix is not written. There are two candidates and they are not the same fix.</p>\n\n  <p>The first is that the recogniser never learned what a shop confirmation box looks like —\nit was trained to tell battle screens from the rest of the game, and a black-bordered\ndialogue in a shop is a negative it apparently never saw enough of. That is answered with\nframes and a retrain.</p>\n\n  <p>The second is that the hold is wrong to re-arm off a single frame at all, whatever the\nrecogniser says. A patience counter that resets to zero on one reading above a loose\nthreshold has no memory of having climbed to 630, and a mechanism that can be revived by\none frame of noise is fragile even when the network under it is right.</p>\n\n  <p>A crew is deciding between them on evidence now. Until it lands, the collapsed path stays\nbehind its flag and out of the promotion workflow, because promoting it would mean shipping\na route that walks into this reliably.</p>\n\n</section>\n",
      "date_published": "2026-09-04T00:00:00+00:00"
    },
    {
      "id": "https://alchemy86.github.io/devlog/posts/teaching-a-network-to-notice.html",
      "url": "https://alchemy86.github.io/devlog/posts/teaching-a-network-to-notice.html",
      "title": "Teaching a network to notice",
      "summary": "Five triggers that read the cartridge were replaced with networks that look at the screen. Held-out accuracy said 1.0000 and the probe said zero false alarms, and both of them were lying — the labels themselves were poisoned.",
      "content_html": "<section class=\"prose\">\n\n  <p>The student plays from four stacked 36×40 greyscale frames in, one of six buttons\nout. That constraint is the whole point of the project, and for months the scaffolding\naround the student quietly broke it.</p>\n\n  <p>The scaffolding is a set of small triggers — <em>a battle has started</em>, <em>this is the\nforest</em>, <em>our lead is hurt</em> — that decide which trained behaviour drives the next\ndecision. Each one used to answer its question by reading the cartridge: <code class=\"language-plaintext highlighter-rouge\">wCurMap</code> for\nthe forest, <code class=\"language-plaintext highlighter-rouge\">wIsInBattle</code> for the battle, the party HP struct for the heal. Point it at\na different emulator and none of those reads exist.</p>\n\n  <p>Over two days, 2026-09-02 and 03, five of them were replaced with networks that look at\nthe picture. Every one of the five was harder than it looked, and the ways they went\nwrong are more useful than the fact they now work.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>What a recogniser is</h2>\n\n  <p>A recogniser is the smallest thing this project trains. Two classes, one question — <em>is\nthis the screen?</em> — over the same observation the student gets, or a crop of it. You\ngive it a pile of frames that are the scene, a pile that are not, and hold some back to\nscore it on.</p>\n\n  <p>Size follows the crop, and the crop matters more than anything else here. A full-frame\nrecogniser is 118,290 parameters. Cropped to the band under the opponent's name it is\n28,178; to the lead's HP bar, 24,082; to the top half of a text box, 6,954.</p>\n\n  <p>None of them touch the student. <code class=\"language-plaintext highlighter-rouge\">models/pixel-student.npz</code> is 122,330 parameters and was\nnot retrained once during any of this — same file, sha256 <code class=\"language-plaintext highlighter-rouge\">b2bb79082c88c486…</code>, before\nand after.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>Held-out accuracy lies</h2>\n\n  <p>The first forest attempt was a single classifier for <em>is this Viridian Forest</em>. It\nscored <strong>1.0000</strong> balanced accuracy on frames it had never seen, and then fired on <strong>37%\nof 1,705,090 real play frames</strong>. Raising the bar did not save it: 15.5% still fired at\n0.999.</p>\n\n  <p>This is structural, not bad luck. A closed two-class network puts everything it has\nnever seen into whichever class is broader, and the held-out split is drawn from the\nframes it <em>was</em> shown — so it cannot contain the failure by construction. For a question\nlike \"which place is this\", the broader class is the positive one, and the recogniser\nconverges on <em>yes</em>.</p>\n\n  <p>The fix is not a better classifier. It is a different question. A place is a scene, and\na scene has no edges. A doorway is an event, and an event has a beginning. Recognise the\nevent.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>The probe lies too</h2>\n\n  <p>So you probe: run the trained recogniser over every corpus on disk and count how often\nit fires where it should be silent. The forest-entry trigger came back with <strong>zero false\nalarms across 1,705,090 frames of 19 links</strong>.</p>\n\n  <p>It then fired inside the player's own house, at p &gt;= 0.999, in <strong>19 of 20 live\ncold-boot runs</strong>. Because that goal holds until an exit trigger clears it, one such fire\nstrands the run for good: a paired N=20 read 0/20 against 11/20 for the version it was\nreplacing.</p>\n\n  <p>Both numbers were correct. A link's corpus <em>stops</em> at its map change, because that is\nwhen its goal fires, and the next link's corpus <em>starts</em> after it. The cross-map stack —\nthree frames of the old room, one of the new — is exactly what a door produces and\nexactly what this recogniser was trained on, and it exists in no ordinary corpus at all.</p>\n\n  <p>A check cannot find a fault in a place it was never shown. Anything whose subject is a\ntransition has been measured against data that structurally cannot contain its worst\nconfusion. The repair was a shard of 4,825 cross-map door fades from six other doors in\nthe opening chain, collected on purpose and used as a probe target.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>The stack drags the last room in with it</h2>\n\n  <figure class=\"pixel\">\n  <img src=\"../assets/img/agentgb/recogniser-forest-entry-positives.png\" width=\"678\" height=\"1386\" alt=\"Eight rows of Game Boy frames. Each row is one decision's four stacked frames, newest on the left. The left-hand frames show Viridian Forest; the right-hand frames show the gatehouse interior the player just walked out of.\" />\n  <figcaption>\n    Eight rows sampled across the forest-entry positives. Each row is one decision's four\n    stacked frames, newest on the left. The left frames are forest; the right frames are\n    the gatehouse interior the player just walked out of.\n  </figcaption>\n</figure>\n\n  <p>Look at the right-hand frames. They are indoors.</p>\n\n  <p>The observation is four frames, so \"the first frame of the forest\" physically carries\nthree frames of the room before it. Measured on the crossing shard: of 600 rows labelled\nmap 51, the oldest channel is the gatehouse in <strong>450</strong>, and only <strong>150</strong> are forest in\nall four. Three quarters of what the first recogniser was taught to call <em>forest entry</em>\nwas mostly indoor-building pixels — which is precisely why it fired in a house.</p>\n\n  <p>The fix is to keep only frames whose four channels are all the target map. Three steps\ninto the forest is the first decision with no gatehouse anywhere in the stack, and\nacross 150 runs it produces just four distinct pictures. That is a fixed shot, not a\nspread, which is what makes it worth recognising.</p>\n\n  <p>The exit is the same trick pointed the other way — the north door, on the way out.</p>\n\n  <figure class=\"pixel\">\n  <img src=\"../assets/img/agentgb/recogniser-forest-exit-positives.png\" width=\"678\" height=\"1386\" alt=\"Eight rows of four stacked Game Boy frames showing the player at the north door of Viridian Forest.\" />\n  <figcaption>\n    The forest exit spread: eight decisions at the north door.\n  </figcaption>\n</figure>\n\n  <p>Its threshold is 0.99, not the 0.999 the entry uses, and the difference was measured\nrather than chosen. At 0.999 the exit misses 37 of 152 real exits. A trigger tuned only\nfor silence goes blind; this project has already lost 11 of 27 runs to one that only\never saw a fully drawn line of text.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>A screen-only trigger, taught by a memory read</h2>\n\n  <p>This is the one worth the whole page.</p>\n\n  <p>The battle gate was trained on every frame where the cartridge byte <code class=\"language-plaintext highlighter-rouge\">wIsInBattle</code> said a\nbattle was happening — <code class=\"language-plaintext highlighter-rouge\">--positive-select \"battle=1\"</code>. It reads nothing but pixels when\nit plays. Its positives were chosen by reading memory.</p>\n\n  <p>The byte and the screen do not agree. On a wild encounter the byte flips a decision\n<em>before</em> the screen changes; on a trainer battle it flips about six decisions <em>after</em>\nthe entry wipe has started. So the pile contains frames that are not battle screens.</p>\n\n  <div class=\"fig-pair\" style=\"max-width:none;\">\n  <figure class=\"pixel\">\n    <p class=\"cap\">Chosen by the byte · poisoned</p>\n    <img src=\"../assets/img/agentgb/recogniser-battle-positives-by-byte.png\" width=\"678\" height=\"2418\" alt=\"Fourteen rows of four stacked Game Boy frames, labelled battle-byte. Row 0 is Route 1 grass with the player and a ledge. Rows 1, 3, 7 and 11 contain entirely black rectangles instead of battle screens.\" />\n    <figcaption>\n      Row 0 is the overworld — grass, a ledge, the player. Rows 1, 3, 7 and 11 are the\n      screen wiping to black. Every one of these was labelled <em>a battle is on\n      screen</em>.\n    </figcaption>\n  </figure>\n  <figure class=\"pixel\">\n    <p class=\"cap\"><span class=\"accent\">Chosen by the phase</span> · honest</p>\n    <img src=\"../assets/img/agentgb/recogniser-battle-positives-by-phase.png\" width=\"678\" height=\"2418\" alt=\"Fourteen rows of four stacked Game Boy frames, labelled battle-started. Every row shows a drawn battle scene with sprites and a text box; none is an entirely black frame.\" />\n    <figcaption>\n      The same gate's positives after the fix, selected on the announcement frames instead\n      of the byte. Same pile, same shape, no black frames anywhere in it.\n    </figcaption>\n  </figure>\n</div>\n\n  <p>Across the whole pile: <strong>1,572 of 3,632</strong> selected rows are the entry wipe, and <strong>1,130\nof them — 31.1% — contain at least one entirely black frame</strong>. The gate was being taught\nthat <em>a battle is on screen</em> includes <em>the screen is black</em>, which is also every door\nfade in the game.</p>\n\n  <p>The numbers never showed it. Held-out balanced accuracy 1.0000, every one of 227 genuine\nbattles caught at every threshold, and a stubborn floor of a handful of false alarms per\nhalf-million frames that four rounds of patching, a wider patch budget and more epochs\nall failed to move: 8, then 2, then 5, on different links each time. Not a threshold\nproblem, not a capacity problem. The label.</p>\n\n  <p>The repair was a new per-frame field recorded at collection time, marking the first run\nof decisions after a battle begins on which the game has something to say — <code class=\"language-plaintext highlighter-rouge\">&lt;NAME&gt;\nwants to fight!</code> for a trainer, <code class=\"language-plaintext highlighter-rouge\">Wild &lt;SPECIES&gt; appeared!</code> for an encounter. One rule,\nsymmetric, nothing to edit as the game world grows.</p>\n\n  <p>Honest labels: 2,060 rows, <strong>zero</strong> containing a black frame. That took the gate from\n<em>refused after four rounds of patching</em> to passing with no patched negatives at all —\n<strong>0 false alarms in 549,918 frames at 0.999</strong>, all 227 battles still caught.</p>\n\n  <p>There is a cost. The gate is now shut during the entry wipe, so the battle pair does not\ntake the wheel for those few decisions. That is the right answer: nothing on screen says\n<em>battle</em> yet, and a gate that opened on a black screen would open on every door in\nKanto.</p>\n\n  <p>This generalises. Every screen recogniser in this project selects its positives on a\ncartridge label. Where the label and the picture agree frame for frame that is free.\nWhere they can disagree — a transition, a fade, a warp, a battle start — the bug is\nwaiting, and nothing on the training side can see it, because the network learns the\nwrong label perfectly.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>Crop to the thing itself</h2>\n\n  <p>Telling a trainer battle from a wild one by sight comes down to one band of the screen.\nA trainer's party is drawn as a row of Poké Balls under their name while the\nchallenge line is up. A wild encounter never draws one.</p>\n\n  <figure class=\"pixel\">\n  <img src=\"../assets/img/agentgb/recogniser-battle-kind-trainer-crop.png\" width=\"678\" height=\"1690\" alt=\"Rows of four stacked Game Boy battle frames with a narrow band under the opponent's name outlined in red, and beneath each row the same band blown up, showing a row of Poké Balls.\" />\n  <figcaption>\n    The trainer-kind positives. Each row shows the four-frame stack with the crop outlined\n    in red, and beneath it the same band blown up — all the network is handed.\n  </figcaption>\n</figure>\n\n  <p>Two decisions later the row is gone and the same band carries the enemy HP bar, which\nreads identically in both kinds of fight. The signal exists only at the start: 346 of\n346 recorded trainer battles show it, for a median of 2 decisions, range 2 to 2.</p>\n\n  <p>Cropped to that band, the recogniser fires on <strong>0 of 1,019,244</strong> probed frames at 0.95\nwhile catching all 346 — and the probe deliberately includes three wild-battle corpora,\nwhere a fire would be a real mistake rather than an unseen scene.</p>\n\n  <p>The same argument, put more sharply, produced the heal trigger. The design note is worth\nquoting:</p>\n\n  <div class=\"pullquote\">\n  <p>\n    A declared region is a hard, structural restriction on what a recogniser can see, not\n    a hope that a balanced corpus will make it ignore the rest.\n  </p>\n  <cite>The heal trigger's design note</cite>\n</div>\n\n  <figure class=\"pixel\">\n  <img src=\"../assets/img/agentgb/recogniser-lead-hp-bar-positives.png\" width=\"678\" height=\"1950\" alt=\"Rows of four stacked Game Boy battle frames with the lead Pokémon's HP bar outlined in red, and the crop itself blown up beneath each row. The Pokémon's name, the HP label and the digits all sit outside the red box.\" />\n  <figcaption>\n    The lead's HP bar, outlined in red on each frame of the stack, with the crop itself\n    beneath. The Pok&eacute;mon's name, the <code>HP:</code> label and the digits all sit\n    outside the box.\n  </figcaption>\n</figure>\n\n  <p>That crop is 24,082 parameters and cannot see the name or the level, by construction\nrather than by hoping.</p>\n\n  <p>It also cannot be trusted on its own. Ungated, it reads <strong>33% of 1,898,768 real play\nframes</strong> as <em>low HP</em> — every one an overworld frame whose bar region is a patch of\ngrass. The HP bar is only drawn during a battle, so the bar reading is only ever taken\ninside the battle gate above. Gated, twelve of twenty-four probe links contribute no\nframes at all, because none of them contains a battle.</p>\n\n  <p>Gated and measured against frames whose recorded HP already settles the answer: <strong>42\nfalse alarms in 71,482 frames across 24 links, 0.059%, with 1,035 of 1,035 genuine\noccurrences caught.</strong></p>\n\n  <p>One thing that measured worse is worth the space, because it points the other way.\nLooking at the pile showed <strong>84.1% of its 67,935 positives were gate-shut</strong> — the intro\nwipe, the stats sub-screen, the move list, none of them drawing a bar at all. Cutting\nthem is obviously the right thing to do. Paired at the same seed and epochs, it takes\nheld-out accuracy <em>up</em>, 0.9946 to 0.9997, and the false-alarm rate on the frames the\ntrigger will really be asked about the <em>wrong way</em>, 0.48% to 1.73%. Held-out accuracy\nlied about the fix for held-out accuracy lying.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>A trigger that holds must latch</h2>\n\n  <p>The battle pair does not just fire; it holds the wheel until the fight ends. The first\nwiring asked the entry recogniser again every decision.</p>\n\n  <p>That cost the chain 9/30 down to 2/30. The rival fight fell to 19/30 and eleven runs of\nthirty ran out their budget standing in Oak's lab.</p>\n\n  <p>The reason, measured over real fights: the gate reads under its own entry bar on a large\nminority of a battle's frames — the attack flash, the move menu, the damage animation.\nOver 20,000 sampled battle frames it clears 0.999 on <strong>31.4%</strong> of them in the rival\nfight and 41.6% on Route 1. Swept all the way down to 0.005, only 79–95% clear the bar;\nthere is a hard core it reads as near-zero at any threshold. Its longest run of readings\nbelow 0.5 <em>while the battle is genuinely still on</em> is a median of 5 to 9 and a <strong>maximum\nof 16 consecutive decisions</strong>, which no single-frame bar can tell apart from a real\nending.</p>\n\n  <p>So the marker fires once, latches, holds, and is released by a separate condition. Three\nchanges, no retraining and no new weights: a latched group keeps the wheel whatever the\ngate currently reads; the release has to disagree 24 decisions running, half again\nbeyond the worst observed 16; and entry and release are different numbers, 0.999 and\n0.5. Using one number for both is what caused it.</p>\n\n  <p>The rival fight went back to 30/30 and <code class=\"language-plaintext highlighter-rouge\">stuck_in_battle</code> from 26 to 1.</p>\n\n  <p>The entry recogniser only has to be good at the entry frame. It already was.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>What actually worked</h2>\n\n  <p><strong>Crop tight.</strong> Every trigger cropped to a band — the text box, the ball row, the HP bar\n— passed on the first or second attempt. The two aimed at whole screens fought back for\na night each.</p>\n\n  <p><strong>Prefer the game's own words.</strong> Where the cartridge announces something out loud, match\nthe text and train nothing. The heal cycle disarms on Nurse Joy saying <code class=\"language-plaintext highlighter-rouge\">fightin</code> — a\nseven-character prefix, chosen so it catches the line while it is still being drawn, and\nchosen over <code class=\"language-plaintext highlighter-rouge\">Thank you!</code> because the shop clerk says that too.</p>\n\n  <p><strong>Train simple, probe broad, patch narrow.</strong> Start with the scene's own non-scene frames\nas the negative class and nothing else. Probe everywhere. Add only the areas measured to\nbe confused. The alternative is mapping the entire game as <em>no</em>.</p>\n\n  <p><strong>Refuse.</strong> If no threshold satisfies both bars, ship nothing.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>Where it stands</h2>\n\n  <p>Nothing in the config the student now runs reads cartridge memory. Of its twelve goals,\neleven fire from pixels through a recogniser and one fires on a line the game prints on\nscreen; two of the eleven also stand down on a printed line. No map reads, no battle\nbyte, no HP struct.</p>\n\n  <p>The forest crossing over the two days, all N=30 cold boots on the same config, seed 42:</p>\n\n  <table>\n  <thead>\n    <tr>\n      <th>Change</th>\n      <th class=\"num\">Crossings</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr><td>forest trigger on the screen, hold evicted by other goals</td><td class=\"num\">0/30</td></tr>\n    <tr><td>hold made to survive another goal's decision</td><td class=\"num\">4/30</td></tr>\n    <tr><td>heal trigger rebuilt, having fired 383 times inside the forest</td><td class=\"num\">9/30</td></tr>\n    <tr><td>battle triggers on the screen, hold re-checked every frame</td><td class=\"num\">2/30</td></tr>\n    <tr><td>battle triggers latched</td><td class=\"num\">8/30</td></tr>\n    <tr><td><strong>heal chamber moved to the HP bar</strong></td><td class=\"num\"><strong>12/30</strong></td></tr>\n  </tbody>\n</table>\n\n  <p>The last row carries its own caveat: paired over the same 30 seeds the heal change\ngained 8 runs and lost 4, which at this sample size is not a proven improvement (McNemar\nexact p=0.39). What it did establish is that the trigger now fires when it should —\n<code class=\"language-plaintext highlighter-rouge\">go-heal-center</code> went from firing in 20 of 30 episodes to 29, and every one of those 29\nended at Viridian's own counter.</p>\n\n  <p>The third row is the one to notice. A trigger firing where it should not does not just\nmisbehave locally — the heal trigger was firing 383 times inside Viridian Forest, a room\nwith no Pokémon Centre counter in it, and evicting the forest walking lesson 22\ntimes. It was the single largest cause of the crossing failing, and the fix was in a\ndifferent goal entirely.</p>\n\n  <p>And the honest comparison: the same 25-link config with all five cartridge reads still\nin place crossed the forest in <strong>41 of 60</strong> agents. Screen-only currently costs ground.</p>\n\n  <p>That is not a like-for-like measurement — 60 agents against 30 runs, and the two seed\ntheir attempts differently — so read the direction and not the size. The direction is\nclear enough, and it is the price of the constraint rather than an argument against it.\nA trigger that reads the cartridge cannot leave the building.</p>\n\n  <p>Every figure here is N=30 or smaller against a project convention of 3,000 attempts.\nThese are screens, not certifications.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>One command</h2>\n\n  <p>All of this is now <code class=\"language-plaintext highlighter-rouge\">agentgb trainscene</code>: select the positives, train, probe real play,\nsweep the threshold on both sides, and print a registry entry — or refuse.</p>\n\n  <p>It refuses by default if a trigger fires even once where it should be silent, because a\ntrigger behind a hold strands the whole run on a single false positive. It refuses if\nany genuine occurrence is missed, counting occurrences as episodes rather than frames,\nso a long fully drawn tail cannot carry a trigger that misses every half-drawn entry.</p>\n\n  <p>It refuses in practice and not only in principle. The first trigger it was ever pointed\nat in anger — the Pokémon Centre counter — came back refused on round one, with\n21 of 22 probed areas firing.</p>\n\n  <p>Rebuilding the forest-entry trigger with it, natural negatives alone: held-out balanced\naccuracy 1.0000, and 21,295 false alarms in 1,751,142 frames, 1.2% even at 0.999.\nRefused, with 21 of the 23 probed areas named and the flag to paste back printed\nunderneath. With those negatives added: <strong>zero false alarms at every threshold from 0.8\nto 0.999, all 150 crossings still caught</strong>, the weakest at p=0.999974. Three and a half\nminutes.</p>\n\n  <p>The other half is not a command. Dump the positives, look at the montage, and ask\nwhether every row is the thing you meant. It has now caught three poisoned piles where\nevery number said clean, and a person spotted each of them by eye.</p>\n\n</section>\n",
      "date_published": "2026-09-03T00:00:00+00:00"
    },
    {
      "id": "https://alchemy86.github.io/devlog/posts/a-perfect-score-and-361567-false-alarms.html",
      "url": "https://alchemy86.github.io/devlog/posts/a-perfect-score-and-361567-false-alarms.html",
      "title": "A perfect score and 361,567 false alarms",
      "summary": "A recogniser scored a held-out balanced accuracy of 1.000 and then fired on more than a quarter of 1,383,924 frames of real play. Five rounds of training, one of them poisoned by the tool's own advice, and the bug that actually ended the runs was mechanical.",
      "content_html": "<section class=\"prose\">\n\n  <p>The recogniser had one job: say whether the player is standing in Viridian City. It is the\nsight half of a <em>give-back</em> — lose a fight in Viridian Forest, the cartridge blacks the party\nout two maps away, and the lesson the run had earned is thrown away with it. Hold that lesson\ninstead, and hand it back the moment he is somewhere it knows.</p>\n\n  <p>It scored a held-out balanced accuracy of 1.000.</p>\n\n  <p>Then the probe swept it over 1,383,924 frames of real play from 21 links it had never been\ntrained on. At 0.999 — the tightest threshold in the sweep — it fired on 361,567 of them.\nTwenty-six per cent. It had learned to say <em>yes</em>.</p>\n\n  <p>That is not bad luck, it is the shape of the question. A closed two-class network puts\neverything it has never seen into whichever class is broader, and the held-out split is drawn\nfrom the frames it <em>was</em> shown, so it cannot contain that failure by construction. Ask <em>which\nplace is this</em> and the broader class is the positive one.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>Five rounds, and the one that made it worse</h2>\n\n  <p><code class=\"language-plaintext highlighter-rouge\">agentgb trainscene</code> refuses by default. It sweeps both bars at every threshold — the pooled\nfalse-alarm rate over real play, and how many genuine occurrences are still caught, counted as\nepisodes rather than frames — and if no threshold satisfies both it ships nothing and prints\nthe areas it is confused by. Five rounds of that:</p>\n\n  <table>\n  <thead>\n    <tr>\n      <th>Round</th>\n      <th>Negatives</th>\n      <th class=\"num\">False alarms / 1,383,924 at 0.999</th>\n      <th class=\"num\">Verdict</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr><td>1</td><td>natural only</td><td class=\"num\">361,567 &middot; 26.13%</td><td class=\"num\">refused</td></tr>\n    <tr><td>2</td><td>+15 links, 400 rows each</td><td class=\"num\">2,570 &middot; 0.186%</td><td class=\"num\">refused</td></tr>\n    <tr><td>3</td><td>the refusal's own printed flag</td><td class=\"num\">—</td><td class=\"num\">killed</td></tr>\n    <tr><td>4</td><td>+13 links, 3,000 rows each</td><td class=\"num\">5,257 &middot; 0.380%</td><td class=\"num\">refused</td></tr>\n    <tr><td>5</td><td><strong>positives narrowed to <code>mode=0</code></strong></td><td class=\"num\"><strong>12 &middot; 0.0009%</strong></td><td class=\"num\"><strong>pass</strong></td></tr>\n  </tbody>\n</table>\n\n  <p>Every reported round caught 1,500 of 1,500 genuine occurrences. Round 4 is the one to look at: thirteen\nmore areas of corrections, seven times as many rows each, and it came out worse than round 2.</p>\n\n  <p>So the residual got dumped as a montage and looked at. Ninety-two per cent of it was one\nscreen — the nickname naming grid, map 40 at tile (5,3). A grid of dark glyphs on a light\nfield, which at 40×36 is a town. Four rounds of arithmetic had not said that, and no\naggregate was ever going to.</p>\n\n</section>\n\n<div class=\"fig-pair\" style=\"max-width:none;\">\n  <figure class=\"pixel\">\n    <p class=\"cap\">Chosen by the byte · poisoned</p>\n    <img src=\"../assets/img/agentgb/recogniser-battle-positives-by-byte.png\" width=\"678\" height=\"2418\" alt=\"Fourteen rows of four stacked Game Boy frames. Row 0 is Route 1 grass with the player and a ledge. Rows 1, 3, 7 and 11 contain entirely black rectangles instead of battle screens.\" />\n    <figcaption>\n      A different trigger, the same failure, from the day before. Rows 1, 3, 7 and 11 are the\n      screen wiping to black; row 0 is plain overworld grass. Every one was labelled <em>a\n      battle is on screen</em>.\n    </figcaption>\n  </figure>\n  <figure class=\"pixel\">\n    <p class=\"cap\"><span class=\"accent\">Chosen by the phase</span> · honest</p>\n    <img src=\"../assets/img/agentgb/recogniser-battle-positives-by-phase.png\" width=\"678\" height=\"2418\" alt=\"Fourteen rows of four stacked Game Boy frames. Every row shows a drawn battle scene with sprites and a text box; none is an entirely black frame.\" />\n    <figcaption>\n      The same pile after the selector was narrowed. Nothing was retrained differently and no\n      corrections were added &mdash; the positives just stopped containing frames that were not\n      the thing. That story is <a href=\"teaching-a-network-to-notice.html\">the previous\n      post</a>.\n    </figcaption>\n  </figure>\n</div>\n\n<section class=\"prose\">\n\n  <p>The Viridian fix was the same move. Positives narrowed from <em>every frame on map 1</em> to\n<code class=\"language-plaintext highlighter-rouge\">map=1,mode=0</code> — the town <strong>outdoors</strong>, with a menu drawn over it no longer counting as the\ntown. 94,409 frames over 527 tiles.</p>\n\n  <p>That took it to <strong>12 false alarms in 1,383,924 frames</strong>, 1,500 of 1,500 occurrences still\ncaught, weakest genuine fire at p=1.000000. Eleven of the twelve are on one link and the\ntwelfth is inside the Viridian Mart. Threshold 0.999 rather than the command's recommended\n0.99, which is a deliberate departure: the take-the-lowest rule exists because the Game Boy\ndraws text letter by letter and a tight trigger goes blind on a half-drawn line, and a town is\nnot drawn progressively. Twelve frames against 251, identical recall.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>The tool poisoned its own round</h2>\n\n  <p>Round 3 is missing from the table because it was killed rather than reported.</p>\n\n  <p>When <code class=\"language-plaintext highlighter-rouge\">trainscene</code> refuses, it names the areas that fired and prints a ready <code class=\"language-plaintext highlighter-rouge\">--negatives</code> flag\nlisting them. Pasting that flag back in is the obvious next move, and here it was the wrong\none: <code class=\"language-plaintext highlighter-rouge\">--negatives</code> takes <strong>whole episodes, with no selector</strong>. Three of the links it named are\nViridian City almost end to end — <code class=\"language-plaintext highlighter-rouge\">into-the-viridian-mart</code> is 99.0% map 1,\n<code class=\"language-plaintext highlighter-rouge\">north-out-of-viridian</code> 98.8%, <code class=\"language-plaintext highlighter-rouge\">into-the-pokemon-center</code> 98.7%.</p>\n\n  <p>So the scene being recognised went into the <em>no</em> pile. About 18% of that round's negatives were\nthe thing itself. Held-out balanced accuracy fell 1.000 → 0.927 and stalled, and the round was\nabandoned.</p>\n\n  <p>The probe was not wrong to name those links — it scores them only on their out-of-scope frames,\ncorrectly. The advice it prints from that is what does not survive contact with a link whose\ncorpus <em>is</em> mostly the scene. Check a patch link's own map distribution before pasting.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>Zero false alarms, then 41 in a town</h2>\n\n  <p>The forest-entry trigger, built the day before, had the cleanest numbers on the project: 150 of\n150 real crossings caught at 0.999, and <strong>zero</strong> false alarms pooled over 495,902 frames across\n23 corpora — including a shard of cross-map door fades collected on purpose, because a link's\ncorpus stops at its map change and the next one starts after it, so the states a run passes\nthrough in between exist in no ordinary corpus at all.</p>\n\n  <p>Then a 30-run cold-boot arm came back with <code class=\"language-plaintext highlighter-rouge\">forest-walk-npcbox</code> firing <strong>41 times on map 1</strong>,\nViridian City. It was the last goal driving in 16 of the 18 failures, and 15 of the 18 ended\ninside the Viridian Mart at the full 8,660-decision budget, pressing <code class=\"language-plaintext highlighter-rouge\">left</code>.</p>\n\n  <p>That reads exactly like a false positive, and the structural argument above says a probe cannot\nrule one out. Two crews landed on that goal independently on the same day.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>It was innocent</h2>\n\n  <p>The way to check is to stop probing corpora and score the recogniser on every decision of real\nplay instead. <code class=\"language-plaintext highlighter-rouge\">harvest_goal_false_positives.py</code> replays a sweep's recorded attempts through the\nsame functions a measured run uses, wraps the driver, and writes out the stacks a named goal's\nrecogniser actually fires on outside its own maps. Eighteen replayed failing attempts, 155,880\ndecisions:</p>\n\n  <table>\n  <thead>\n    <tr><th>Where</th><th class=\"num\">Decisions</th><th class=\"num\">Peak probability</th></tr>\n  </thead>\n  <tbody>\n    <tr><td>Viridian City</td><td class=\"num\">3,278</td><td class=\"num\">0.0408</td></tr>\n    <tr><td>Inside the Viridian Mart</td><td class=\"num\">100,728</td><td class=\"num\">5.4e-05</td></tr>\n    <tr><td>Viridian Forest</td><td class=\"num\">—</td><td class=\"num\">0.99996</td></tr>\n  </tbody>\n</table>\n\n  <p>On the one traced seed, the two Viridian decisions it was recorded as \"firing\" on read\n7.7e-17 and 8.9e-08. All 30 episodes' first fire is on map 51, and no episode fires outside the\nforest before entering it.</p>\n\n  <p>The recogniser never fired in the town at all. A <code class=\"language-plaintext highlighter-rouge\">fired</code> event in the run record cannot tell a\nthreshold being cleared from a persisted hold <strong>resuming</strong>, and that one ambiguity is what made\na mechanical bug look like a perception one. A retrain would have changed nothing.</p>\n\n  <p>One real risk did fall out of the harvest, and it is worth naming. The only readings above 0.5\nanywhere outside the forest are fifteen, all in Oak's Lab, peaking at <strong>0.9576</strong>. Dumped and\nlooked at, they are the same shape as the entry positives: a solid black transition frame in\nthe oldest channel of the stack, beside a light textured region and a text box. Which is what\nthat positive class is made of — 150 near-identical frames of one tile, (17,46), with the\ncamera clamped at the forest's southern edge so the lower half of every one is black. It is\nsafe today because the threshold is 0.999 and not 0.95. That is a thinner margin than anybody\nknew they had.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>The fault was mechanical</h2>\n\n  <p><code class=\"language-plaintext highlighter-rouge\">end_condition.persist_through_other_goals</code> exists because a hold that spans a long stretch of\nplay loses the wheel the moment anything else wins a single decision; without it the forest\ncrossing scored 0/30. As first written it made a hold survive the decisions it does not drive,\nand left its ending observable only on the ones it does.</p>\n\n  <p>Lose a Bug Catcher fight inside Viridian Forest. The cartridge blacks the party out to Viridian\nCity while the battle hold is driving. The forest hold is asked nothing, the battle hold\nreleases at map 1, the forest hold resumes — and the forest's own walking adapter drives the\nrun around a town it has never seen for the rest of its budget. The event immediately before\nevery single non-forest fire is a battle hold releasing at map 1 or 0: fourteen trainer\nbattles, one wild.</p>\n\n  <p>The version this trigger replaced was gated on <code class=\"language-plaintext highlighter-rouge\">wCurMap</code> and was immune by construction. It\nre-asked memory every decision, so a teleport stopped it on the next one. Moving to the screen\nremoved the memory read and quietly removed that property with it. <strong>When a mechanism replaces\na memory read, check which properties the memory read was silently providing.</strong></p>\n\n  <p>The replacement needs no weights. <code class=\"language-plaintext highlighter-rouge\">release_on_text</code> sweeps a list of phrases at the top of\nevery decision, before selection, for every persisted hold. A list rather than one phrase,\nbecause a decision samples one frame in 32 and the game draws a line letter by letter:\n<code class=\"language-plaintext highlighter-rouge\">BLUE is out of / useable POKéMON!</code> is up for two sampled decisions, <code class=\"language-plaintext highlighter-rouge\">BLU</code> for one mid-draw,\nand <code class=\"language-plaintext highlighter-rouge\">BLUE blacked / out!</code> fully drawn for about one. Two phrases give roughly four decisions of\ncover instead of one.</p>\n\n  <p>Paired on the identical 30 seed pairs, cold boot, seed 42:</p>\n\n  <table>\n  <thead>\n    <tr><th>Whole chain, 30 cold boots</th><th class=\"num\">Crossings</th></tr>\n  </thead>\n  <tbody>\n    <tr><td>persisted hold, no way to end it while evicted</td><td class=\"num\">12/30 &middot; 40.0%</td></tr>\n    <tr><td><strong>hold released on the blackout line</strong></td><td class=\"num\"><strong>25/30 &middot; 83.3%</strong></td></tr>\n  </tbody>\n</table>\n\n  <p>Thirteen gained, none lost, McNemar exact p = 0.00024. Milestones 1 to 24 are 30/30 in both\narms, and the change is provably inert where no blackout happens: all 12 runs that already\nfinished reproduce their exact decision count, 12 of 12, median 2,165.5 either way. Fires on\nmap 1 went 41 → 0; all 270 fires are on map 51; the first fire is on map 51 in 30 runs of 30.\nThe trigger everybody suspected was never touched.</p>\n\n  <p>Of the five that still fail, four are stuck in a forest battle — no PP left, no running from a\ntrainer battle — which is a known gap in fighting competence and not this bug. The fifth\nreleased correctly at the blackout and then wandered into the Mart under a different latched\nlesson.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>What the day cost</h2>\n\n  <p>The give-back that started all of this measured a null, and it is recorded as one. Seven\nrecorded knockout seeds: 2/7 through the forest with no clear, 2/7 clearing, 2/7 clearing and\nhanding back — the same two seeds every time. Thirty cold boots, paired: 12/30 both arms, zero\ngained, zero lost, every one of the 25 milestones identical.</p>\n\n  <p>The mechanism itself is clean. Fifteen of the 30 runs got the lesson handed back, every restore\non map 1 and on that stage alone, zero false hand-backs, zero runs ending still-held. It fires\ncorrectly, costs nothing, and rescues nothing at this sample size, because the thing ending the\nruns was three maps away in a branch of code with no weights in it.</p>\n\n  <p>Five training rounds bought a recogniser that works and does not currently matter. Finding that\nout is what made the next fix a one-line declaration.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>The sequence</h2>\n\n  <p>This is now the written procedure rather than something the crew happens to do.</p>\n\n  <p><strong>1. Dump the positives and look at the montage before training.</strong> Not a description of them —\nthe actual four-frame stacks, in a picture, in front of a person. It has now caught a poisoned\npile three times where every number said clean.</p>\n\n  <p><strong>2. Small cheap tests first.</strong> A tile distribution, a map histogram, one probe over one link.\nAn hour of training is a bad way to discover a bad idea.</p>\n\n  <p><strong>3. Let the tool refuse.</strong> A trigger that fires where it should not is not a trigger. The\ndefault false-alarm bar is 0.0 because a trigger behind a hold strands the whole run on one\nfalse positive — relax it deliberately, on evidence, and say so. This one was relaxed to\n0.0005, on the argument that the exposure is bounded by where the code can ever ask.</p>\n\n  <p><strong>4. Narrow what it learns from before piling on corrections.</strong> Rounds 2 and 4 added 28 links\nof negatives between them and left 5,257 false alarms. Adding <code class=\"language-plaintext highlighter-rouge\">mode=0</code> to the positive selector\nleft 12. Every correction teaches the network another place it is not; a narrower positive\nteaches it what it is.</p>\n\n</section>\n\n<figure class=\"pixel\">\n  <img src=\"../assets/img/agentgb/recogniser-lead-hp-bar-positives.png\" width=\"678\" height=\"1950\" alt=\"Rows of four stacked Game Boy battle frames with the lead Pokémon's HP bar outlined in red, and the crop itself blown up beneath each row. The Pokémon's name, the HP label and the digits all sit outside the red box.\" />\n  <figcaption>\n    The same principle in its structural form: a declared crop. This recogniser is 24,082\n    parameters and cannot see the name or the level, by construction rather than by hoping a\n    balanced corpus makes it ignore them.\n  </figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <p><strong>5. Two aimed rounds, then stop and report the trade-off.</strong> Round 4 was the third and it went\nbackwards. The stopping condition is not \"it passed\", it is \"the next round has a reason\".</p>\n\n  <p><strong>6. Measure in a real run, paired, and report what was gained and what was lost.</strong> Both\nnumbers. 13 gained and 0 lost is a result; 8 gained and 4 lost, which is what an earlier change\non this same chain produced, is not.</p>\n\n  <p>And a seventh that only exists because of today: <strong>check who is driving before blaming what\nrecognised.</strong> Forty-one fires in a town, sixteen of eighteen failures ending under that goal,\nand the recogniser's own peak reading there was 0.0408.</p>\n\n</section>\n",
      "date_published": "2026-09-03T00:00:00+00:00"
    },
    {
      "id": "https://alchemy86.github.io/devlog/posts/exponential-decay-of-belief.html",
      "url": "https://alchemy86.github.io/devlog/posts/exponential-decay-of-belief.html",
      "title": "Exponential decay of belief",
      "summary": "A confidence gate that locks onto one button and never lets go, fixed by letting the belief in it decay instead of banning it. 594 of 600 became 600 of 600, and the same machinery taught the agent to heal itself mid-run.",
      "content_html": "<section class=\"prose\">\n\n  <h2>Fourteen failures, one bug</h2>\n\n  <p>A cold-boot chain scoring 594 of 600 looks, at a glance, like six runs that each went\nslightly wrong in their own way — bad luck spread thin across six hundred attempts. It\nwasn't. Three separate 600-run sweeps produced fourteen failures between them, and every\nsingle one ended the same way: twelve identical actions in a row, the same button, right\nup until the run ran out of decisions and was scored a loss.</p>\n\n  <p>The cause was the confidence gate the agent already relies on to act decisively. Above\n0.80 confidence, it stops sampling and takes the argmax — the single most likely action,\nno randomness. That's the right behaviour almost everywhere in the chain. It's the wrong\nbehaviour on a screen that a no-op cannot change: press a button that does nothing, the\nframe stays exactly as it was, the network sees the same input it just saw, and produces\nthe same output. Confidence in the wrong button doesn't wobble. It locks, and there is\nnothing in a static screen that can ever unlock it.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>Don't ban the action. Let the belief in it decay.</h2>\n\n  <p>The obvious fix is a blocklist — once an action has done nothing N times running, take\nit off the table. It works, and it's also exactly the kind of hard rule that breaks the\nnext time the situation looks a little different. The fix that shipped instead doesn't\nforbid anything. It penalises belief.</p>\n\n  <p>Every time an action fires and the frame doesn't change, a flat amount is subtracted\nfrom that action's logit — its pre-softmax score — before the next decision. Nothing\nelse on the board moves. The other five actions keep whatever scores the network gave\nthem; only the one that just proved it does nothing gets docked.</p>\n\n  <div class=\"pullquote\">\n  <p>Exponential decay of belief.</p>\n  <cite>The framing is the captain's, and it is exact — not a metaphor</cite>\n</div>\n\n  <p>The exactness is in the arithmetic. Subtracting a flat amount <em>D</em> from a logit divides\nthat action's odds against every alternative by <em>e<sup>-D</sup></em> on every repeat — the\nsame shape as an exponential backoff, arrived at from the opposite direction. A backoff\ngrows the wait after a failure; this shrinks the confidence after one. Repeat the no-op\nenough times and the action that looked certain a moment ago stops being the argmax at\nall, sampling opens back up, and the agent tries something else — not because it was\ntold to, but because it stopped believing the thing it was doing was working.</p>\n\n  <p>Whole-chain result: <strong>594 of 600 to 600 of 600</strong>. The specific failure mode the record\ncalls <code class=\"language-plaintext highlighter-rouge\">stuck_in_battle</code> — an agent locked in a real fight, repeating an action combat\nwasn't accepting — went from 4 occurrences to 0.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>The same machinery, pointed at healing</h2>\n\n  <p>Once an agent can notice that repeating something isn't working, the next question is\nobvious: can it notice a good reason to go do something else entirely, mid-chain,\nwithout derailing the chain it's already following? The answer shipped the same day, as\na second mechanism: <strong>chambered goals</strong>.</p>\n\n  <p>A chambered goal has two conditions, decoupled in time. An <em>arm</em> condition, read from\ncartridge memory — the agent has taken damage. A <em>fire</em> condition, read from the screen,\nchecked only once armed — the agent is looking at a Pokémon Center. Take damage, and the\nchamber loads. Later, whenever a Center actually comes into view, it fires: walk in,\nheal at the counter, walk back out, resume whatever the chain was already doing.</p>\n\n  <p>Satisfaction doesn't have to come from the direction the design expects. A blackout\nheals the party too, so it discharges the chamber on its own, with no Center visit at\nall — the condition the mechanism exists to detect stopped being true, and the mechanism\nnotices that as readily as it notices the Center. And because the fire condition's\nrecogniser is never even consulted while the chamber is unarmed, it is the least-exposed\nrecogniser anywhere in the system: arming isn't just a trigger, it's a safety property.\nA screen can only fire this goal at the one moment the agent is actually carrying\ndamage.</p>\n\n  <p>Across the current 600-run certification, <strong>306 runs</strong> take that detour — walk to a\nCenter, heal, walk back out — mid-chain, at zero cost to the chain itself.</p>\n\n</section>\n\n<figure class=\"pixel\">\n  <img src=\"../assets/img/agentgb/pixel-network.png\" width=\"1240\" height=\"2771\" alt=\"A technical sheet drawing the student network: three convolution layers with their live feature maps, a dense layer, and a six-bar softmax output at the bottom.\" />\n  <figcaption>\n    The six-way head both mechanisms above operate against. Decay is a flat subtraction\n    against one of these six bars, before the softmax is taken — nothing upstream of this\n    layer changes, and nothing about the convolutions above it knows the subtraction\n    happened.\n  </figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <h2>How badly hurt he is decides how sure the recogniser has to be</h2>\n\n  <p>A chambered goal still needs to know how confident is confident enough, and that\nthreshold isn't fixed. It's a gradient against how much the arm condition actually hurt:\nbarely scratched, the recogniser has to be almost certain the building in front of it is\na Center before it fires. Badly hurt, a glimpse is enough — the cost of a false negative\ngoes up as the party's health goes down.</p>\n\n  <p>Where that gradient's floor sits was measured, not guessed, one value at a time:</p>\n\n  <div class=\"table-wrap\">\n  <table>\n    <thead>\n      <tr><th>Confidence floor</th><th class=\"num\">N</th><th class=\"num\">Heals fired</th><th class=\"num\">Chain result</th></tr>\n    </thead>\n    <tbody>\n      <tr><td>0.945</td><td class=\"num\">300</td><td class=\"num\">96</td><td class=\"num\">300/300</td></tr>\n      <tr><td>0.94</td><td class=\"num\">300</td><td class=\"num\">100</td><td class=\"num\">300/300</td></tr>\n      <tr><td>0.93</td><td class=\"num\">300</td><td class=\"num\">131</td><td class=\"num\">300/300</td></tr>\n      <tr><td><strong>0.92</strong></td><td class=\"num\">300</td><td class=\"num\">152</td><td class=\"num\"><strong>300/300</strong></td></tr>\n      <tr><td>0.91</td><td class=\"num\">600</td><td class=\"num\">—</td><td class=\"num\">599/600</td></tr>\n    </tbody>\n  </table>\n</div>\n\n  <p>0.92 is the measured last safe rung, and its margin is one notch: drop one more click to\n0.91 and the chain loses a run it wasn't losing before. Every floor from 0.945 down to\n0.92 fires more heals as it loosens and still lands the chain clean — the gradient buys\nmore coverage for free right up until the exact point it doesn't.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>The honest bits</h2>\n\n  <p>The gradient shipped in its measured, governed form. It didn't start there. The first\nversion of the confidence threshold was tuned too hot — loose enough that the recogniser\nit gated fired <strong>13,673 times</strong> over the course of testing it, and five runs got trapped\nstanding at a door, chambering and re-chambering a heal that kept almost-firing. At the\nfloor that actually shipped, 0.92, the same recogniser fires 591 times. The difference\nbetween those two numbers is the entire reason the floor sweep above exists instead of a\nsingle value picked once and trusted.</p>\n\n  <p>A separate change tried to make the Center recogniser more precise by narrowing what it\nwas allowed to look at — cropping the frame down to just the POKé sign over the door,\ninstead of the wider shot that includes the building around it. It scored worse: 77.7%\nagainst the wider crop's 79.6%. The pixel observation the tighter crop produced was\ncorrect; the classifier simply had less to work with than the wider one gave it. That\nresult didn't get deleted for not helping. It's in the record as a negative, because the\nnext person tempted to crop tighter for the same reason should be able to find out it\nalready didn't work.</p>\n\n  <p>And once, earlier in this same stretch of work, a chain got certified, reported and\nmerged while four of the weight files it depended on existed only in a scratch folder —\nreal on the machine that ran the certification, absent from everything committed. The\nbuild didn't catch it because nothing was checking. It does now:\n<code class=\"language-plaintext highlighter-rouge\">tools/test_studentconfig_guards.py</code> test 10 fails the build if any registered goal\npoints at a path that isn't tracked.</p>\n\n</section>\n",
      "date_published": "2026-08-31T00:00:00+00:00"
    },
    {
      "id": "https://alchemy86.github.io/devlog/posts/one-character-becomes-three-thousand.html",
      "url": "https://alchemy86.github.io/devlog/posts/one-character-becomes-three-thousand.html",
      "title": "One character becomes three thousand",
      "summary": "A single character stands in a bedroom, then three thousand of it walk themselves into a Pokéball, in one unbroken shot. Getting there took a stage with no map and six real bugs, most of them nowhere near the camera.",
      "content_html": "<figure>\n  <video controls=\"\" preload=\"metadata\" poster=\"../assets/img/agentgb/livingart-poster.png\" width=\"540\" height=\"540\">\n    <source src=\"../assets/video/agentgb/livingart-bedroom-to-pokeball-mobile.mp4\" type=\"video/mp4\" />\n  </video>\n  <figcaption>\n    The finished shot. One character, alone, in Red's own bedroom — then the room fades\n    as the crowd walks itself outward into a Pokéball, and keeps moving once it arrives.\n    No cut anywhere in this file.\n  </figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <h2>A blank stage, no map, no cartridge room</h2>\n\n  <p><code class=\"language-plaintext highlighter-rouge\">pixellivingart</code> is a third swarm mode alongside AgentGB's existing teacher-run and\ncustom-run films, and it throws out everything a Game Boy map usually provides. No\nwalkable-tile graph, no room, no live emulator beyond one one-time read of the\ncharacter's own sprite pixels straight out of VRAM and OAM — the sprite doesn't depend\non the room, so any saved state serves. Everything else on screen is synthetic: a target\nshape, an assignment of agents to points on it, and a path from wherever each one starts\nto the point it was given.</p>\n\n  <p>A shape is one flag — <code class=\"language-plaintext highlighter-rouge\">pokeball</code>, <code class=\"language-plaintext highlighter-rouge\">text:WORDS</code>, or <code class=\"language-plaintext highlighter-rouge\">image:path.png</code> — and the tile grid\nit gets sampled onto sizes itself to the shape's own ink and the requested crowd, rather\nthan a fixed resolution regardless of either. A filled disc needs a much smaller grid\nthan thin letter strokes for the same agent count to read as a crowd instead of a\nspeckle: the Pokéball, 59.3% foreground at a cheap probe resolution, sizes to a\n96×96 grid for 3,000 agents at 55% target occupancy. Every agent is then handed\nits nearest still-free point on a KD-tree, walks there on the same grid path AgentGB's\nother swarm films already use, and — the whole point of the exercise — does not stop\nonce it arrives. It jitters in place, or the whole shape slowly turns, or agents trade\nplaces with their neighbours on the shape itself. A formation that freezes the instant\nit forms was the one thing rejected outright.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>Six bugs, and only the last one hid</h2>\n\n  <p>The render above is not the first take. The first three were rejected, and the reasons\nkept turning out not to be about the thing that looked wrong.</p>\n\n</section>\n\n<figure class=\"narrow\">\n  <img src=\"../assets/img/agentgb/livingart-tight-start.png\" width=\"1080\" height=\"1080\" alt=\"A single character standing on the floor in a Game Boy bedroom, in front of a TV and desk, facing away from the camera.\" />\n  <figcaption>\n    The true opening frame. One character, on the floor, facing up — not standing on the\n    TV, which is where an early cut had it.\n  </figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <h3>1. Standing on the TV</h3>\n\n  <p>The spawn tile itself was right — map 38, tile (3,6), verified against a live\nscreenshot. What wasn't right was how the room got drawn under it: the background image\nwas anchored by centring the whole room on the spawn point, rather than aligning that\none named tile within the room art. The TV sits near the room's own centre, so the\ncharacter appeared to be standing on it. The fix aligns the tile, not the room's\nmidpoint.</p>\n\n  <h3>2. Facing built backward</h3>\n\n  <p>Every render's first decision had every agent facing \"down,\" hard-coded. This isn't a\nshortcut around a hardware constraint the way a forced facing on a real cartridge run is\n— this stage has no cartridge and no button ever pressed, so a starting facing is free\nsynthetic data. It had simply never been given a real one. The fix threads through the\nsame \"up\" already verified against a live screenshot of that tile.</p>\n\n  <h3>3. Walking four times too fast</h3>\n\n  <p>Every agent glided into formation at four times normal walking speed. AgentGB's own\nconvention for one decision of real game time is fixed — 32 frames at a documented,\nun-adjustable 59.7275 frames a second — and this stage's default substep count fell\nshort of it: 8 drawn per decision instead of the 32 the convention calls for. Set to 32,\nthree thousand individually-timed approach paths produce a steady, staggered arrival\nwith no further tuning; nobody needed to be slowed down by hand once the base pace was\nhonest.</p>\n\n  <h3>4. The camera chasing its own crowd</h3>\n\n  <p>Early passes built the camera's keyframes by re-centring on wherever the crowd's\nbounding box happened to sit at that instant. As the crowd dispersed unevenly toward the\nshape, that centre visibly crept sideways — the frame kept pulling out from a point that\nwas quietly moving. The fix: every keyframe now shares one fixed centre, the crowd's own\nposition at the very first frame, and only ever grows the framing's size around it.\nBecause every shot's centre is identical, the interpolation between any two of them has\nnothing left to pan across. Not a smaller drift. No pan at all.</p>\n\n  <h3>5. A shape that was never centred on anything</h3>\n\n  <p>Fixing all four of the above produced a render that still looked wrong: the Pokéball sat\nin a corner of the frame, a wide band of pure white on one side that no amount of camera\ntuning could close. By this point the camera was genuinely correct — a fixed centre, a\npure zoom. The fault was one level down: the shape's own target points were sampled in a\ncoordinate space with no relationship to wherever the render's one spawn point happened\nto land, so nothing in the shape's own geometry was centred on anything a camera could\nanchor to. The fix shifts every target point once, before spawns or bounds are derived\nfrom them, so the shape's true centroid lands exactly on the origin — which is also\nwhere the lone starting character now stands, so the crowd visibly erupts outward from\nthe one point the camera never lets go of.</p>\n\n  <h3>6. The whole crowd stepped in unison, once</h3>\n\n  <p>The approved render still had one visible fault: for several seconds, the whole crowd\nappeared to take one slow step together, hold, then step again — thousands of\nindependently-timed paths moving in lockstep. Two plausible causes were tried and\ndiscarded before the real one turned up under direct measurement: binning the render's\nown frame-to-frame pixel difference by decision showed every single decision, everywhere\nin the film, split cleanly into a near-zero-change half and a large-change half. Every\nagent was gliding for the first half of a decision and standing frozen for the second,\nsimultaneously, for the entire 112 seconds — the freeze was just usually invisible,\nbecause a compression pass quietly collapses long runs of near-identical frames. The one\nplace that collapse couldn't hide it was the few seconds where the background art itself\nwas continuously fading, which stopped the frozen frames from matching each other\nclosely enough to be thrown away. The cause was one shared \"how far into this glide are\nwe\" value, computed once a frame rather than once an agent, and clamped to finish at the\nhalfway point instead of the end. Making it progress across the whole span removed the\nfrozen half everywhere, not just where it happened to be visible.</p>\n\n</section>\n\n<div class=\"fig-pair\">\n  <figure>\n    <p class=\"cap\">Mid-dispersal</p>\n    <img src=\"../assets/img/agentgb/livingart-mid-dispersal.png\" width=\"1080\" height=\"1080\" alt=\"Thousands of tiny character sprites fanning outward from a fading bedroom in a symmetric diamond pattern.\" />\n    <figcaption>Fifteen seconds in. The room is still fading, faintly, at the centre of the diamond every agent's own grid path traces on the way out.</figcaption>\n  </figure>\n  <figure>\n    <p class=\"cap\"><span class=\"accent\">Formed</span></p>\n    <img src=\"../assets/img/agentgb/livingart-formed-pokeball.png\" width=\"1080\" height=\"1080\" alt=\"Three thousand tiny character sprites arranged into a clean, centred Pokéball shape: top disc, bottom disc, the gap band, the centre button.\" />\n    <figcaption>The same crowd, arrived. Top disc, bottom disc, the gap band, the centre button — and every dot is still a walking, breathing character, not a frozen picture.</figcaption>\n  </figure>\n</div>\n\n<section class=\"prose\">\n\n  <h2>A camera that cannot lose the crowd</h2>\n\n  <p>An earlier attempt at this shot picked keyframes by hand, and it produced a render with\nseveral seconds of pure white in the middle: the room had faded, the keyframes were\nstill centred on the old spawn tile, and by then the crowd had already walked far enough\naway that neither the room nor a single agent was inside the crop. A hand-guessed\nkeyframe is a bet against how fast the world's own content moves, and a wrong bet\nproduces exactly this — a camera looking at empty floor.</p>\n\n  <p>The fix doesn't re-tune the guess. The render now logs, for every output frame that\nactually survives deduplication, the true pixel bounding box of every agent's own drawn\nposition — one manifest entry per real frame that ends up in the finished file. A\nseparate tool reads that manifest and derives camera keyframes from it directly, then\nverifies its own output by re-implementing ShowReel's own camera interpolation in Python\n— the same geometric zoom, the same eased pan, the same easing curve — and checking that\nevery single logged frame is actually contained in the resulting viewport at that\nframe's own moment in the film. Wherever one isn't, it inserts a corrective keyframe\nexactly there and checks again, until every frame passes or it refuses to ship at all.</p>\n\n  <p>For this shot that's 13 keyframes covering 6,496 logged frames, every one sharing the\nidentical fixed centre — (1584.0, 1584.0), to the decimal, confirmed directly from the\nfilm's own keyframe file rather than a log claiming it. The same pass also caught a\nsmaller fault in the opening hold: the camera sat as frozen as the crowd during it, when\nonly the crowd was supposed to. A small camera ramp through the hold fixed that without\ntouching how the world itself holds. A blank frame in the middle of this shot isn't\nunlikely now. It's checked, on every render, against what the render actually drew.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>What it actually took</h2>\n\n  <p>The crowd's own arithmetic: a 96×96 grid, 3,000 agents, a mean walk of 40 tiles to\neach one's assigned point, the longest single approach 64 decisions — plus the 140\ndecisions every agent spends alive and moving once it arrives. At 32 sub-frames a\ndecision that's 6,528 canvases composited, about 29.6ms apiece, roughly 193 seconds of\ndrawing before ffmpeg ever starts; the encode itself took another 187 seconds, peaking\nat 5.5GB resident. The finished master: 6,735 frames, 3136×3136, 112.25 seconds at\n60fps, with 0.5% of the canvases coming out as exact duplicates of the one before and\ndropped rather than written twice.</p>\n\n  <p>None of it needed a second cartridge running anywhere — the per-agent cost here was\nnever \"run a Game Boy 3,000 times,\" it was \"paste one already-decoded sprite into a\ncanvas, once a frame,\" the same shape of work this project's other swarm films had\nalready measured as cheap. A host-wide out-of-memory event did take out a later render\npass mid-flight once — forty-five processes killed machine-wide, an ffmpeg encoder among\nthe largest. The recovery was to resume from whichever of the render's own segments had\nalready finished rather than start over, capped at three workers running at once so it\ncouldn't happen the same way twice.</p>\n\n</section>\n",
      "date_published": "2026-08-29T00:00:00+00:00"
    },
    {
      "id": "https://alchemy86.github.io/devlog/posts/three-bytes-a-cell-doing-nothing.html",
      "url": "https://alchemy86.github.io/devlog/posts/three-bytes-a-cell-doing-nothing.html",
      "title": "Three bytes a cell, doing nothing",
      "summary": "AsciiWorldEngine's frame buffer has carried a per-cell background colour plane since the plate work landed, wired into every output path and never turned on. Filling it borrowed a reference engine's look — and because nothing about the world model had to change to do it, the result shipped as a --view mode instead of a flag.",
      "content_html": "<section class=\"prose\">\n\n  <h2>The gap was one sentence</h2>\n\n  <p>Every building here already carries a named hue — one of six facades, from a neon grid\ngreen to a red terminal orange — and every vehicle and street surface picks its own\ncolour the same way. Walk the street and the red tower, the cyan tower and the yellow\ntower are plainly three different buildings. But the hue was only ever the glyph's\ncolour. The cell behind each character stayed black, so at any distance a building\ndissolved back into a scatter of coloured dots on black — the exact thing an ASCII\nrenderer is always accused of looking like.</p>\n\n  <p>The reference engine does the opposite: the wall is a filled block of one hue with\ndetail drawn <em>on</em> it, the road is a colour, a taxi is a filled yellow shape with wheels.\nNothing in its frame is a bright glyph floating on black. The whole difference between\nthe two comes down to one sentence: it colours the cell; this one coloured the glyph.</p>\n\n</section>\n\n<div class=\"fig-pair\">\n  <figure>\n    <p class=\"cap\">Classic</p>\n    <img src=\"../assets/img/asciiworldengine/view-street-classic.png\" width=\"1400\" height=\"750\" alt=\"A street in AsciiWorldEngine's classic view: towers rendered as coloured characters on a black background, the road between them unlit.\" />\n    <figcaption>Coloured glyphs on black — the look every capture on this site has shown until now.</figcaption>\n  </figure>\n  <figure>\n    <p class=\"cap\"><span class=\"accent\">Blocks</span></p>\n    <img src=\"../assets/img/asciiworldengine/view-street-blocks.png\" width=\"1400\" height=\"750\" alt=\"The same street in --view blocks: each tower filled with a dark shade of its own hue behind the glyphs, and the road now a lit grey surface with visible lane markings and kerbs.\" />\n    <figcaption>Same seed, same position, same everything else. The road stops being the largest black shape in frame.</figcaption>\n  </figure>\n</div>\n\n<div class=\"pullquote\">\n  <p>&ldquo;It colours the cell; this one coloured the glyph.&rdquo;</p>\n  <cite>The whole gap, in one sentence</cite>\n</div>\n\n<section class=\"prose\">\n\n  <h2>The plumbing was already there</h2>\n\n  <p>The surprise is how little of this turned out to be new. The frame buffer has carried a\nper-cell background plane — three bytes a cell — since registration plates needed one: a\nplate is black characters on yellow, which a foreground colour alone can't say. Every\nway the engine turns a frame into a picture already reads it — the terminal writer emits\nthe colour run, the evidence SVG draws a filled rectangle under the text, the wasm\nbridge hands the whole plane to the browser's own painter. None of that is new code.\nIt's been wired end to end since the plate work landed, and on every frame that wasn't a\nregistration plate it painted nothing, because nothing ever set it.</p>\n\n  <p>That made the fill a rendering change, not a data one. Every place the renderer already\npicks a glyph's colour already has the hue in hand — <code class=\"language-plaintext highlighter-rouge\">Grid::put</code> just also writes a flat\n0.30 downscale of that same colour into the background plane and raises a flag saying\nthe cell is filled. One factor on all three channels keeps the hue exact and keeps the\nper-cell lightness variation that gives a wall its depth: a brighter wall cell gets a\nbrighter, still-dark fill. The world model needed nothing new — no field on a building,\na car or a cell — because the fill is derived at the moment it's drawn, not stored\nanywhere.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>Why a view, not a flag</h2>\n\n  <p>Because the background plane costs nothing while it's black, turning the fill on could\nbe gated behind a single per-frame check — the same check that already made the plate\nwork free on every frame without one. That's what let this ship as <code class=\"language-plaintext highlighter-rouge\">--view\nclassic|blocks|middle</code>, read the same way <code class=\"language-plaintext highlighter-rouge\">--weather clear|rain|downpour</code> already is,\nrather than as a setting that quietly changed the default look. Classic isn't a second\ncode path kept alive for compatibility; it's the fill code simply not running. Every\ncapture and every film already on this site stays exactly the frame it was shot as.</p>\n\n  <p>That distinction was checked, not assumed: three scripted <code class=\"language-plaintext highlighter-rouge\">--capture</code> walks in <code class=\"language-plaintext highlighter-rouge\">--view\nclassic</code> came back byte-identical to the frames the engine wrote before any of this\nlanded. And it's worth being straight about the reference clip here too — its whole four\nminutes are the new look, with no old-view section and no side-by-side. That it can fall\nback to a bare-glyph mode is a credible claim about how engines like this are usually\nbuilt, but it isn't demonstrated in the source. Proving reversibility here, rather than\nassuming it, is the actual difference between a view and a repaint.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>The three things that weren't free</h2>\n\n  <p>Deriving the fill from a hue the engine already had was the easy 90%. Three things\nneeded real work:</p>\n\n  <ul>\n    <li><b>The ground had gaps.</b> A road cell whose glyph is a space was simply skipped, so\nthe street was already speckled — colour on the characters, black between, and the\nroad is the single largest black area in any frame. In a filled view the ground now\nwrites its fill even where no glyph lands. It's the single change that opens the\nstreet up the most.</li>\n    <li><b>Contrast had to be designed, not just derived.</b> A glyph on a fill of its own hue\ncan vanish if the two lightnesses sit too close. A flat 0.30 downscale — tried by eye\nagainst 0.24 and 0.38 side by side — keeps the ink about 3.3× brighter than its\nown field at every lightness, so it can't disappear even in the tightest case: amber\non amber, a hue with no chroma to fall back on, only luminance.</li>\n    <li><b>Plates had to stay plates.</b> The legibility scorer that grades a registration\nreads runs of coloured background, so once the whole city has one, a filled frame\ncould read as one enormous plate. It didn't need fixing — the scorer already\ndisambiguates a plate from its surroundings by a separate plate mask, not by the\nbackground colour itself — but that had to be checked, not assumed, and it's now a\nnamed test rather than a hope.</li>\n  </ul>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>Indoors, the same rule holds</h2>\n\n  <p>The reference engine's buildings read as one flat hue apiece; this engine's walls vary\nlightness cell to cell for depth, and that variation was the one thing not up for\nnegotiation. Fill and keep the gradient, or the change is a downgrade wearing an\nupgrade's clothes.</p>\n\n</section>\n\n<div class=\"fig-pair\">\n  <figure>\n    <p class=\"cap\">Classic</p>\n    <img src=\"../assets/img/asciiworldengine/view-interior-classic.png\" width=\"1400\" height=\"750\" alt=\"Inside a room in AsciiWorldEngine's classic view: walls and floor drawn as coloured characters on black.\" />\n    <figcaption>A room, same as every interior shot on this site until now.</figcaption>\n  </figure>\n  <figure>\n    <p class=\"cap\"><span class=\"accent\">Blocks</span></p>\n    <img src=\"../assets/img/asciiworldengine/view-interior-blocks.png\" width=\"1400\" height=\"750\" alt=\"The same room in --view blocks: walls and floor filled with a shaded colour field behind the glyphs, the per-cell lightness that shows depth still visible on the walls.\" />\n    <figcaption>Same room, same position. The wall still reads as a wall with depth on it, not a flat panel.</figcaption>\n  </figure>\n</div>\n\n<section class=\"prose\">\n\n  <h2>What it costs, measured here</h2>\n\n  <p>Filling the background is new work on the hottest path in the renderer, so it was\nmeasured rather than assumed — six interleaved pairs of 400 frames at 180×60,\n<code class=\"language-plaintext highlighter-rouge\">tools/bench-view.sh</code>, the same binary run in <code class=\"language-plaintext highlighter-rouge\">--view classic</code> and <code class=\"language-plaintext highlighter-rouge\">--view blocks</code>\nalternately so machine load lands on both equally:</p>\n\n  <div class=\"table-wrap\">\n  <table>\n    <thead>\n      <tr><th>View</th><th class=\"num\">mean ms/frame</th><th class=\"num\">delta</th></tr>\n    </thead>\n    <tbody>\n      <tr><td>classic</td><td class=\"num\">0.614</td><td class=\"num\">—</td></tr>\n      <tr><td>blocks</td><td class=\"num\">0.732</td><td class=\"num\">+19.2%</td></tr>\n    </tbody>\n  </table>\n</div>\n\n  <p class=\"note\" style=\"margin-top:14px;\">\n  The machine wasn't fully settled while this ran — load average sat around 7–8 rather than\n  the under-0.5 the project's own benchmarking notes ask for — but the method is interleaved\n  pairs precisely so steady background load lands on both sides equally, and it reproduces\n  the project's own +19% figure for the street almost exactly. Most of the cost is in\n  <em>paint</em>, not the renderer itself: a filled frame emits a terminal colour-change\n  sequence wherever the fill colour changes, where a classic frame emits none. Classic stays\n  the default, and stays free — nothing pays this cost unasked.\n</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>The render got faster along the way</h2>\n\n  <p>Profiling render broken down by pass, to see where the fill's cost was landing, found\ntwo passes doing work once a column that only depends on the row — sky was recomputing\nan elevation angle per cell instead of once a row, and ground was re-deriving the same\nworld cell down a column where one screen cell spans several rows of it. Both were\nhoisted out.</p>\n\n  <p>Measured the same way, interleaved against the build immediately before this change, six\npairs of 400 frames at 180×60:</p>\n\n  <div class=\"table-wrap\">\n  <table>\n    <thead>\n      <tr><th></th><th class=\"num\">mean ms/frame</th><th class=\"num\">delta</th></tr>\n    </thead>\n    <tbody>\n      <tr><td>before</td><td class=\"num\">0.644</td><td class=\"num\">—</td></tr>\n      <tr><td>after, <code>--view classic</code></td><td class=\"num\">0.614</td><td class=\"num\">&minus;4.7%</td></tr>\n    </tbody>\n  </table>\n</div>\n\n  <p class=\"note\" style=\"margin-top:14px;\">\n  The \"after\" binary includes the whole view-mode change — the extra branch on every pass\n  that checks whether to fill — and it's still faster than the build before it existed,\n  because the two hoists pay for the new branching several times over. Under the same\n  machine conditions as the table above, so read the absolute numbers with the same\n  caution; the direction and the rough size of the win are the finding. <code>walls</code>,\n  the single most expensive pass, was left alone — it has no redundant work to hoist out,\n  and chasing a few percent there risks the look for not much.\n</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>What shipped</h2>\n\n  <p>Three named views, run the same way weather is and toggled live with <code class=\"language-plaintext highlighter-rouge\">B</code> while you walk:</p>\n\n  <div class=\"table-wrap\">\n  <table>\n    <thead><tr><th>View</th><th>What it does</th></tr></thead>\n    <tbody>\n      <tr><td><code>--view classic</code></td><td>coloured glyphs on black — the look every capture on this site showed before this change, and still the default</td></tr>\n      <tr><td><code>--view blocks</code></td><td>a filled colour field behind every surface — buildings, road and traffic alike</td></tr>\n      <tr><td><code>--view middle</code></td><td>the buildings filled, the road and traffic left bare — a lit skyline over a dark street</td></tr>\n    </tbody>\n  </table>\n</div>\n\n  <p>All three work everywhere the engine runs — <code class=\"language-plaintext highlighter-rouge\">--vista</code>, <code class=\"language-plaintext highlighter-rouge\">--capture</code>, <code class=\"language-plaintext highlighter-rouge\">--film</code>,\n<code class=\"language-plaintext highlighter-rouge\">--doorway</code>, <code class=\"language-plaintext highlighter-rouge\">--lift</code>, the browser build — because the fill isn't a fourth picture the\nrenderer draws. It's the frame buffer's own background plane, finally filled.</p>\n\n</section>\n",
      "date_published": "2026-08-28T00:00:00+00:00"
    },
    {
      "id": "https://alchemy86.github.io/devlog/posts/the-one-clean-miss.html",
      "url": "https://alchemy86.github.io/devlog/posts/the-one-clean-miss.html",
      "title": "The one clean miss",
      "summary": "The captain asked ShowReel to study a specific YouTube editor's display style. Going technique by technique, six of the seven it needed already existed. The seventh was a colour grade, and it still isn't built.",
      "content_html": "<section class=\"prose\">\n\n  <h2>What was actually checked</h2>\n\n  <p>Nobody on this crew watched a full video of his with sound. The browser tooling\navailable has no audio pipeline, and none of his videos had captions turned on. The one\ntechnique with real weight behind it — a specific fake-depth trick applied to flat\nscreenshots — came from two independent tutorials that reverse-engineer his shots frame\nby frame, one of which he commented on himself, a thin but real signal that the\nbreakdown was accurate enough for him to endorse rather than correct.</p>\n\n  <p>Everything else — cut rhythm, sound design, the exact grade — is genre-level inference,\nnot something verified against his own footage, and it's named as such below rather than\nfolded in as if it were checked the same way.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>The technique with real evidence behind it</h2>\n\n  <p>Cut a flat screenshot — a tweet, a channel page — into two or three depth planes, space\nthem apart, and push a camera across the stack. It reads as looking into the image\nrather than at a picture of it. Both tutorials that clone his shots build entire videos\naround exactly this move.</p>\n\n  <p>ShowReel already had every piece the shot needs, just not assembled into one move. A\nscene already holds an ordered stack of layers, each with its own camera. A still with\ntransparency, layered over a background and given an independent camera rate, already is\na parallax composite — nothing new to render, just nothing that composed it in a single\ncall.</p>\n\n</section>\n\n<div class=\"table-wrap\">\n  <table>\n    <thead>\n      <tr><th>Technique</th><th>Verdict</th></tr>\n    </thead>\n    <tbody>\n      <tr><td>Camera pushes over stills and clips, timed to narration</td><td>already built</td></tr>\n      <tr><td>Kinetic caption pop-ins, synced word by word</td><td>already built</td></tr>\n      <tr><td>Callouts and pull-ups over evidence</td><td>already built</td></tr>\n      <tr><td>Stinger sound effects on cuts</td><td>already built</td></tr>\n      <tr><td>A driving music bed, ducked under narration</td><td>already built</td></tr>\n      <tr><td>Fake-depth parallax over a flat screenshot</td><td>built the same day</td></tr>\n      <tr><td>Colour grade — desaturated, contrast-pushed</td><td><strong>still missing</strong></td></tr>\n    </tbody>\n  </table>\n</div>\n\n<section class=\"prose\">\n\n  <h2>The one that got built</h2>\n\n  <p><code class=\"language-plaintext highlighter-rouge\">Content::Parallax</code> takes a handful of depth-plane images and one authored camera move,\nand gives every plane its own fraction of that move — <code class=\"language-plaintext highlighter-rouge\">depth: 1.0</code> follows it exactly,\n<code class=\"language-plaintext highlighter-rouge\">0.0</code> sits still, anything else scales the departure, which is what actually reads as\ndepth: nearer things moving more.</p>\n\n  <p>Measured directly, single-threaded: a three-plane stack at 1920×1080 over 4000×2500\nsource planes costs about 45 ms a frame, against about 15 ms for one ordinary\nstill-plus-camera layer at the same size — close to linear in the plane count, as it\nshould be. The worked example — three 3200×1800 planes, threaded — averages 15.0\nms/frame across the whole clip, because most of it sits at the wide end of the push,\nwhere every plane's own mip pyramid picks a small, cheap level.</p>\n\n</section>\n\n<div class=\"fig-pair\">\n  <figure>\n    <p class=\"cap\">Wide, before the push</p>\n    <img src=\"../assets/img/showreel/parallax-wide.png\" width=\"1152\" height=\"648\" alt=\"A synthetic night skyline before the camera has moved: a row of buildings of varying heights under a gradient sky with a pale moon or sun low behind them.\" />\n    <figcaption>\n      Three depth planes, one authored move, no cut applied yet.\n    </figcaption>\n  </figure>\n  <figure>\n    <p class=\"cap\"><span class=\"accent\">Pushed</span> · 7s later</p>\n    <img src=\"../assets/img/showreel/parallax-pushed.png\" width=\"1152\" height=\"648\" alt=\"The same skyline pushed in on the light source, with buildings visibly at different depths — nearer ones larger and further into frame than distant ones.\" />\n    <figcaption>\n      Nearer buildings have moved further across the frame than the skyline behind them —\n      the whole of the depth cue.\n    </figcaption>\n  </figure>\n</div>\n\n<section class=\"prose\">\n\n  <h2>The one that didn't</h2>\n\n  <p>Confirmed by reading the render pipeline, not assumed: there is no global grade pass\nanywhere in the crate. Compositing and blurring happen; nothing tone-maps a finished\nframe. That's the one technique on the list ShowReel genuinely cannot do.</p>\n\n  <p>It's real, and it's small — a single lift/gamma/gain or contrast-and-saturation pass,\none more stage in the per-frame pipeline, touching nothing about text, camera or\ntransitions. It's also ranked last of everything on the list, on purpose: a correctly\ngraded film with no parallax evidence shots in it looks less like this genre than an\nungraded one that has them. The parallax convenience shipped the same day the study did.\nThe grade pass is still just a line item.</p>\n\n</section>\n\n<div class=\"pullquote\">\n  <p>&ldquo;The reputation is a design decision applied consistently, not a feature.&rdquo;</p>\n  <cite>What separates a look from a checklist</cite>\n</div>\n\n<section class=\"prose\">\n\n  <h2>What actually separates the two</h2>\n\n  <p>It isn't a missing feature. It's that his channel applies one trick — split the evidence\ninto depth planes, time the push to the voice — with total consistency across an entire\ncatalogue. Building the grade pass closes what's left of the capability gap. Nothing\ncloses the craft gap except someone actually cutting a film that way, every time, on\npurpose.</p>\n\n</section>\n",
      "date_published": "2026-08-28T00:00:00+00:00"
    },
    {
      "id": "https://alchemy86.github.io/devlog/posts/the-chiptune-that-outgrew-its-blog-post.html",
      "url": "https://alchemy86.github.io/devlog/posts/the-chiptune-that-outgrew-its-blog-post.html",
      "title": "The chiptune that outgrew its blog post",
      "summary": "A demo video needed music with no licence to worry about, so a 114-line Python script wrote its own chiptune. The captain asked why that lived beside a blog asset instead of inside the renderer that times things to pictures for a living — and it moved.",
      "content_html": "<section class=\"prose\">\n\n  <h2>A problem worth avoiding</h2>\n\n  <p>The lift ride is a demo video for this blog — a walk through AsciiWorldEngine's city and\nup in the tower's glass lift, cut as a short film in ShowReel. It needed music, and this\nis a public site, so the rule was blunt: source audio legally and keep the licence, or\nship the clip silent. Nobody wanted to be the one explaining a licensing question later.</p>\n\n  <p>Instead of hunting for something labelled free-to-use and hoping the label held up, the\nanswer was to not need one. <code class=\"language-plaintext highlighter-rouge\">chiptune.py</code> — a 114-line Python script, committed\nalongside the video assets — synthesises three voices in the NES/SID idiom: a\nduty-cycled pulse bass, a pulse-wave arpeggio lead with a little vibrato, and noise\nbursts standing in for hats and kick. Its own docstring says what it is: self-authored,\nnothing sampled, nothing pulled off the internet, public domain.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>The obvious question</h2>\n\n  <p>The captain saw it and asked the question that actually mattered: if a generator times\nits own output to a video and plays inside that video, why does it live next to a blog\nasset instead of inside the renderer built to time things to pictures? Should it not be\na feature, in Rust?</p>\n\n  <p>It now is. ShowReel's own commit for it calls the Python file what it was — \"the\ndevlog's throwaway <code class=\"language-plaintext highlighter-rouge\">chiptune.py</code>\" — and ports the idiom faithfully rather than treating\nit as a spec to improve on: the same pulse bass, the same arpeggio lead, the same noise\ndrums, none of it reinvented.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>What shipped</h2>\n\n  <p>A track's source can now be generated music instead of a file. A <code class=\"language-plaintext highlighter-rouge\">Music</code> spec resolves\nto a synthesised WAV at exactly the point a file track's <code class=\"language-plaintext highlighter-rouge\">asset</code> resolves to a path, so\nfrom there it is an ordinary audio input — placement, gain, fades, multi-track mixing\nand the mobile cut all compose for free rather than through a second audio path built to\nmatch the first.</p>\n\n  <p>Authoring is one word in the film file, mirroring the shorthand the colour grade already\nuses:</p>\n\n</section>\n\n<figure class=\"code\">\n  <pre><code>\"audio\": [\n  { \"music\": \"funk\" },\n  { \"music\": { \"mood\": \"dreamy\", \"key\": \"C\", \"bpm\": 96 }, \"fade_out\": 2.0 }\n]</code></pre>\n  <figcaption>\n    A bare mood word for the reference tune, sized to the film, or an object for key, bpm and\n    tempo fit — <code>examples/music_demo.film.jsonc</code> in the ShowReel repository.\n  </figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <h2>The timing is the point</h2>\n\n  <p>With no duration given, the tune sizes itself to exactly the film's length, so it never\nneeds trimming and never hard-cuts to silence. <code class=\"language-plaintext highlighter-rouge\">fit: \"film\"</code> goes further: the authored\ntempo is treated as a target and nudged so a whole number of bars spans the film\nexactly, landing the final downbeat on the last frame. Space scene cuts a whole number\nof bars apart and every cut becomes a chord change, generated to fit rather than\nhand-aligned after the fact.</p>\n\n  <p>The self-contained demo film proves it: four bar-aligned scenes at 128 BPM, and its\nthree hard cuts land within about 7 ms of a downbeat in the rendered audio.</p>\n\n</section>\n\n<figure>\n  <video controls=\"\" preload=\"metadata\" poster=\"../assets/img/showreel/music-demo-poster.png\" width=\"720\" height=\"406\">\n    <source src=\"../assets/video/showreel/music-demo-mobile.mp4\" type=\"video/mp4\" />\n  </video>\n  <figcaption>\n    ShowReel's own proof file, rendered end to end with no assets — every background is a\n    colour, the only source is the chiptune the one <code>music</code> track synthesises. Each\n    hard cut lands on the downbeat of bar 5, 9 or 13; the progress bar under the second\n    scene's title is that beat grid drawn on screen.\n  </figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <h2>Checked against the thing it replaced</h2>\n\n  <p>The Rust port was checked honestly against the Python original rather than assumed\nfaithful: envelope and spectrum correlation of roughly 0.9997 and 0.9999. The one\ndeliberate difference is a seeded random generator in place of the Python script's\nglobal one, which means renders now reproduce — same film, same audio, every time.\nThat's a real improvement on the thing it replaced, not just a port of it.</p>\n\n</section>\n\n<div class=\"pullquote\">\n  <p>&ldquo;It was in the wrong repo, as a throwaway script, until someone asked the obvious\n  question.&rdquo;</p>\n  <cite>Why this one is worth telling</cite>\n</div>\n\n<section class=\"prose\">\n\n  <h2>Back where it started</h2>\n\n  <p>The feature went straight back into the video that caused it. The AsciiWorldEngine lift\nfilm's soundtrack is arranged to its own cuts, not laid under them: sparse under the\nopening terminal, a riser through the bar before the reveal, the full band dropping in\nwith a crash on the cut to the city, driving through the street and the ride, and a\none-bar resolve to the tonic at the end so it lands rather than getting chopped. The\nShowReel feature landed at 19:03; the recut using it landed at 19:21. Eighteen minutes.</p>\n\n</section>\n",
      "date_published": "2026-08-28T00:00:00+00:00"
    },
    {
      "id": "https://alchemy86.github.io/devlog/posts/three-ways-this-cartridge-was-wrong.html",
      "url": "https://alchemy86.github.io/devlog/posts/three-ways-this-cartridge-was-wrong.html",
      "title": "Three ways this cartridge was wrong about itself",
      "summary": "A verdict decided by which checks failed above it, a subroutine that ate a measurement, and two checks that skipped on every console, forever.",
      "content_html": "<section class=\"prose\">\n\n  <h2>The run decided the verdict, not the machine</h2>\n\n  <p><code class=\"language-plaintext highlighter-rouge\">GB-CYC-07</code> shipped once in a form that zeroed the timer counter and then restarted the\ndivider. Three cycles separate those two writes, and whether the tapped bit falls inside\nthem depends on the counter phase the check was entered in — which is set by how much\ncode ran above it.</p>\n\n  <p>So the verdict was decided by which checks failed earlier. It passed on one emulator and\nfailed on SameBoy, and swapping the earlier failures swapped the answer.</p>\n\n  <p>Restart the counter first and zero the timer after it, and sweep more than one delay\nrather than sampling once. Anything that reads a timer edge and does not do both is\nmeasuring the rest of the run.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>A subroutine that quietly ate the measurement</h2>\n\n  <p><code class=\"language-plaintext highlighter-rouge\">FlipSpeed</code> runs the documented STOP-based speed-switch sequence and, like every\nsubroutine in that file, makes no promise about which registers survive it. It loads <code class=\"language-plaintext highlighter-rouge\">A</code>\nrepeatedly on the way through.</p>\n\n  <p>A check that measured something into <code class=\"language-plaintext highlighter-rouge\">A</code>, called <code class=\"language-plaintext highlighter-rouge\">FlipSpeed</code> to return to the starting\nspeed, then compared against <code class=\"language-plaintext highlighter-rouge\">A</code>, was comparing <code class=\"language-plaintext highlighter-rouge\">FlipSpeed</code>'s own leftover value.</p>\n\n  <p>It does so silently, producing a plausible and constant wrong number rather than a\ncrash. It shipped in <code class=\"language-plaintext highlighter-rouge\">GB-PPU-07</code>'s double-speed half and was caught only because the\nwrong number (<code class=\"language-plaintext highlighter-rouge\">$1</code>) disagreed with an independent measurement on two unrelated emulators\nthat had already established the right one (<code class=\"language-plaintext highlighter-rouge\">$2</code>).</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>Two checks that skipped on every console, forever</h2>\n\n  <p>This is the best of the three, because nothing about it looks wrong.</p>\n\n  <p>The build did not pass <code class=\"language-plaintext highlighter-rouge\">rgbfix -c</code>, so the ROM's header byte at <code class=\"language-plaintext highlighter-rouge\">$0143</code> was <code class=\"language-plaintext highlighter-rouge\">$00</code> — and\na real Color console boots a cartridge with no Color flag into DMG compatibility mode,\nwhere <code class=\"language-plaintext highlighter-rouge\">KEY1</code> and double speed do not exist at all.</p>\n\n  <p>Meanwhile the cartridge's own console detection still correctly reported CGB, because it\nreads the boot handover registers, which do not care about the cartridge's header.</p>\n\n  <p>So a double-speed check written the ordinary way built, linked, and skipped on every\nrun, on every console, forever. Nothing looked wrong until somebody specifically asked\nwhether it had ever run. Confirmed by building both ways and watching <code class=\"language-plaintext highlighter-rouge\">GB-CYC-09</code> and\n<code class=\"language-plaintext highlighter-rouge\">GB-PPU-07</code> go from permanently-skip to actually-run, with no change to any other\ncheck's verdict on any console.</p>\n\n  <div class=\"callout\">\n  <p class=\"eyebrow\">Which is why a skip is counted separately</p>\n  <p>\n    A skip is not a pass, and it is not a failure either. Each one prints its own\n    reason in the run, so a skipped row is never silent — and two of the 102 do not\n    judge at all: they report, printing the number they saw and leaving the verdict\n    to a reader who has real hardware, because no published reference settles what\n    the right answer is.\n  </p>\n</div>\n\n</section>\n",
      "date_published": "2026-08-27T00:00:00+00:00"
    },
    {
      "id": "https://alchemy86.github.io/devlog/posts/the-transfer-controller-owns-the-bus.html",
      "url": "https://alchemy86.github.io/devlog/posts/the-transfer-controller-owns-the-bus.html",
      "title": "The transfer controller owns the bus",
      "summary": "Object DMA is usually modelled as a copy that blocks the CPU. It is also an address-bus conflict, and the sprite scan is on the other end of those lines.",
      "content_html": "<section class=\"prose\">\n\n  <p>The transfer controller has no address bus of its own. While a transfer runs it drives\nthe object-memory address lines — and the picture processor's object scan is on the\nother end of them.</p>\n\n  <p>So for the eighty dots of the scan the PPU cannot read a single entry. Its Y/X latch\nkeeps whatever it last held, and all forty object slots are judged against that one\nstale pair.</p>\n\n  <p>Modelling that took the Shootout from 238 to 239 of 264 and Gambatte from 3,613 to 3,617\nscored rows, with zero losses and everything else byte-identical on both picture\nengines. One row — but it was <code class=\"language-plaintext highlighter-rouge\">ashiepaws/strikethrough.gb</code>, the first row that suite has\never scored here.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>The constant was derived, not chosen</h2>\n\n  <p>The controller takes the bus a fixed number of dots after the write to <code class=\"language-plaintext highlighter-rouge\">$FF46</code>, and that\nnumber is the one free parameter in the whole model. It came out of eight ROMs.</p>\n\n  <p>Gambatte's <code class=\"language-plaintext highlighter-rouge\">late_sp{00,01,02,39}x_{1,2}</code> each put the write one machine cycle either\nside of one scan slot. <code class=\"language-plaintext highlighter-rouge\">sp00x_2</code> finds object 0 while <code class=\"language-plaintext highlighter-rouge\">sp01x_1</code> misses object 1, which\nbrackets the arm. The <code class=\"language-plaintext highlighter-rouge\">sp02x</code>/<code class=\"language-plaintext highlighter-rouge\">sp39x</code> pair — same DMA phase, different slot — rules out\nevery uniform shift.</p>\n\n  <p>Then it was swept across the whole 811-row <code class=\"language-plaintext highlighter-rouge\">oamdma/</code> group:</p>\n\n  <div class=\"table-wrap\">\n  <table>\n    <thead>\n      <tr><th>Arm delay (dots)</th><th class=\"num\">0</th><th class=\"num\">1</th><th class=\"num\">2</th><th class=\"num\">3</th><th class=\"num\">4</th></tr>\n    </thead>\n    <tbody>\n      <tr><td>Gambatte <span class=\"mono\">oamdma/</span> rows passing, of 811</td><td class=\"num\">742</td><td class=\"num\"><strong>744</strong></td><td class=\"num\"><strong>744</strong></td><td class=\"num\">738</td><td class=\"num\">738</td></tr>\n    </tbody>\n  </table>\n</div>\n\n  <p>The scan reads on even dots, so 1 and 2 are the same machine. A curve with a flat top\ntwo dots wide, and a physical reason for the width — that is what a derived constant\nlooks like, as opposed to the one value that made a favourite test go green.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>The data half came first, and was worth four hundred rows</h2>\n\n  <p>Three days earlier the same physical rule was modelled from the other side: while the\ntransfer runs, the CPU and the controller share one bus, so the CPU's reads of most of\nthe map come back as whatever the transfer is putting on it.</p>\n\n  <p>Gambatte went from 2,682 to 3,083 of the rows scored at the time. Four hundred rows,\nfrom modelling a bus conflict instead of a copy.</p>\n\n  <div class=\"pullquote\">\n  <p>\n    A peripheral that moves bytes is doing two things at once, and only one of them\n    is the copy.\n  </p>\n</div>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>And then a sibling project found the flag</h2>\n\n  <p><a href=\"../projects/gbselftest.html\">GBSelfTest</a>'s object-DMA check found a real bug in this\nmodel on the day it was written: the flag the PPU keeps about a running transfer was\ncleared on one of the two paths that can notice the transfer has ended, and not the\nother. Once it latched, the object scan never read object memory again for the rest of\nthe session.</p>\n\n  <p>Thousands of rows across five public suites were byte-identical either way. <a href=\"a-hundred-checks-in-one-session.html\">Why they\ncould not see it →</a></p>\n\n</section>\n",
      "date_published": "2026-08-27T00:00:00+00:00"
    },
    {
      "id": "https://alchemy86.github.io/devlog/posts/the-red-we-refused-to-fix.html",
      "url": "https://alchemy86.github.io/devlog/posts/the-red-we-refused-to-fix.html",
      "title": "The red we refused to fix",
      "summary": "One sweep would have turned a failing test green. Taking it would have moved every Color cartridge's divider on the evidence of a single row.",
      "content_html": "<section class=\"prose\">\n\n  <h2>Why sweeping would have been wrong</h2>\n\n  <p>Bully waits for <code class=\"language-plaintext highlighter-rouge\">LY &gt;= $90</code> before reading the divider. So what it pins is not the\ncounter. It is the <em>phase between the system counter and the picture processor</em> at boot\nhand-off — two unknowns multiplied together.</p>\n\n  <p>And no published ROM measures where a Color boot ROM leaves the PPU for a Color\ncartridge. Fitting one unknown to absorb another would have moved every Color\ncartridge's divider, and with it its audio phase and its random number generator, on the\nevidence of one row.</p>\n\n  <div class=\"pullquote\">\n  <p>\n    A test going green is not evidence when the change that made it green touched\n    two things and the test only measures their product.\n  </p>\n</div>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>The counter did change, later, for a different reason</h2>\n\n  <p>A second independent source arrived. Gambatte's <code class=\"language-plaintext highlighter-rouge\">div/start_inc_{1,2}_cgb04c</code> take the\ngenuine Color path and pin both the divider's value <em>and</em> the exact machine cycle its\nlow byte wraps on, at a fixed distance with no <code class=\"language-plaintext highlighter-rouge\">LY</code> wait.</p>\n\n  <p>So they measure the counter alone — precisely the confound the original objection named.\nThe constant moved on their evidence.</p>\n\n  <p>Bully's row is still red, byte-identical in both picture modes, because the PPU half is\nuntouched. Two crews' work settled half a question; the other half is still open, and\nthe red row is what says so.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>The other red that stays</h2>\n\n  <p>Blargg's <code class=\"language-plaintext highlighter-rouge\">oam_bug</code> fails on a Color console here. All eight sub-tests pass on DMG, where\nthe object-memory corruption defect is modelled faithfully. Color silicon has no such\ndefect, so real hardware fails that ROM too. Passing it would be the bug.</p>\n\n  <p>Both rows are kept on the board rather than excluded, because a suppressed red is\nindistinguishable from a fixed one six months later.</p>\n\n</section>\n",
      "date_published": "2026-08-27T00:00:00+00:00"
    },
    {
      "id": "https://alchemy86.github.io/devlog/posts/the-one-failure-in-twelve-thousand.html",
      "url": "https://alchemy86.github.io/devlog/posts/the-one-failure-in-twelve-thousand.html",
      "title": "The one failure in twelve thousand",
      "summary": "Four certification cells of 3,000 attempts each produced exactly one failure. Somebody was standing on the corner tile.",
      "content_html": "<section class=\"prose\">\n\n  <p>It reproduces exactly. A certification's start states are a pure function of the link,\nthe held-out split, the seed and the spread, so no rollout has to be kept for an attempt\nto be run again: attempt #705 of 3,000, held-out start (31,26), start offset 1,772\nframes. Re-run, it fails the same way. The fifteen other attempts from that same tile\nall reach the goal in 30 to 67 decisions.</p>\n\n</section>\n\n<figure class=\"pixel\">\n  <img src=\"../assets/img/agentgb/bagcheck-the-one-failure.png\" width=\"760\" height=\"528\" alt=\"A Game Boy screen showing the player character standing in a street column, facing up, with another character directly above blocking the way and a shop entrance visible at the top of the screen.\" />\n  <figcaption>\n    The last frame of the run. The Mart is at the top of the screen and the student\n    never reaches it: it walks up column 31, meets somebody standing on (31,20) — the\n    corner tile, the one place its route has to turn — and presses up into that person.\n    The shop is in view, the person is in the way, the budget is gone.\n  </figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <h2>The anatomy</h2>\n\n  <div class=\"table-wrap\">\n  <table>\n    <tbody>\n      <tr><td>Where it stood</td><td>(31,21) for 533 of 600 decisions</td></tr>\n      <tr><td>What it pressed there</td><td><code>up</code> 177, <code>start</code> 89, and 267 more with a menu on screen</td></tr>\n      <tr><td>What the teacher would have pressed</td><td><code>left</code> 177 — a clean 177-for-177 divergence</td></tr>\n      <tr><td>Its own probabilities on those 177</td><td>p(<code>up</code>) median 0.926; p(<code>left</code>) median 0.020, max 0.107</td></tr>\n      <tr><td>One press of <code>left</code>, at the moment it is stuck</td><td>reaches the goal in 79 decisions</td></tr>\n    </tbody>\n  </table>\n</div>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>Three explanations, all closed by measurement</h2>\n\n  <p><strong>Not the route.</strong> The teacher, driving from the same tile with the same offset, reaches\nthe Mart in 30 decisions. There is a way round and the privileged player finds it.</p>\n\n  <p><strong>Not a wanderer who would eventually move.</strong> The person steps twice, at decisions 13\nand 61, reaches (31,20), and then does not move for the remaining 533 decisions — about\n17,000 frames, or 4.7 minutes of game time. Checked under four different player\nbehaviours from the stuck moment, including backing off a tile and standing still, and\npacing 266 tiles up and down. It stays parked in all four.</p>\n\n  <p><strong>Not the bag check.</strong> The run spends 301 of its 600 decisions with a menu on screen,\nbut the menus are not what pins the person: an arm that presses only <code class=\"language-plaintext highlighter-rouge\">b</code> runs the\noverworld continuously for 533 decisions and the person does not move either.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>Which weights these rows belong to</h2>\n\n  <p>Every rate for this link predates a corpus re-collection on 23 Aug 2026. The round-0\ncorpus it was trained from carried 105 leaked frames; a fresh corpus collected under the\nfix audits clean, and no student has been retrained or re-certified on it. The\ncertification file does not record which weights it ran, so these rows are marked\nunattributed rather than filled in from a directory convention.</p>\n\n  <p>This is a measurement of one reproducible attempt. It has not been re-measured since.</p>\n\n</section>\n",
      "date_published": "2026-08-27T00:00:00+00:00"
    },
    {
      "id": "https://alchemy86.github.io/devlog/posts/the-number-that-could-have-sunk-it.html",
      "url": "https://alchemy86.github.io/devlog/posts/the-number-that-could-have-sunk-it.html",
      "title": "The number that could have sunk it",
      "summary": "Could Remotion open on Pok&eacute;mon Blue's title screen, pull back to the whole world map, and burst out real battle footage from where it happened? Two of the three ingredients already existed. The one real unknown came back at 4.3 milliseconds a frame.",
      "content_html": "<section class=\"prose\">\n\n  <h2>Two of the three already existed</h2>\n\n  <p>PixelGB already renders every one of Pokémon Blue's 226 maps into one picture,\n6,832 × 7,024, 48.0 megapixels, with the seams between towns and routes measured\nrather than eyeballed. AgentGB already turns a swarm of parallel cold boots into real\nGame Boy footage — the same runs this blog already writes about, not a re-enactment of\nthem. And the narrow phone cut this needed was already policy rather than a new problem:\nTelegram's <code class=\"language-plaintext highlighter-rouge\">sendVideo</code> refuses 60fps outright, at any file size, so a 720p/30fps pass\nhas been the standard delivery output for a while.</p>\n\n  <p>Two-thirds of the job was already sitting on disk, done, and nobody had noticed.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>The piece that didn't exist</h2>\n\n  <p>Nothing in the house could zoom or pan across a still that large, or choreograph several\nindependently-timed clips appearing at chosen positions on cue. That's a camera and a\nscheduler, not a renderer — and it's exactly what a tool like Remotion is for.</p>\n\n  <p>Remotion's own documentation doesn't put a number on the one thing that actually\nmattered here: whether a smooth pull-back over an image that size performs at all. Not\n\"renders eventually\" — holds something close to real time, for a shot that needs nine\ncontinuous seconds of it. That was the one genuine unknown, and it was the kind of thing\nthat could have ended the idea before it started.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>Building our own instead of adopting theirs</h2>\n\n  <p>The licence was never actually the obstacle. Remotion is free for one person working\nalone, personal or commercial use either way, so the open-source-versus-paid-seat\nquestion people expect never came up. What decided it was smaller than that: the piece\nRemotion would actually contribute — a camera and clip choreography over footage we\nalready generate — is a well-understood technique, and building it cost about the same\nas learning somebody else's framework well enough to trust it. Minus the ~300MB Chromium\ndownload and a Node toolchain nothing else here uses.</p>\n\n  <p>So: ShowReel. A Rust crate — eighteen modules, a little over 8,600 lines — that takes a\ndescription of a film and renders it, deterministically, to an mp4. <code class=\"language-plaintext highlighter-rouge\">tiny-skia</code> and\n<code class=\"language-plaintext highlighter-rouge\">rustybuzz</code> draw the pixels and the glyphs; <code class=\"language-plaintext highlighter-rouge\">ffmpeg</code> encodes. No browser, no Node, no\nheadless Chromium. From the point the Remotion question was answered to a rendered film\nwas under two hours.</p>\n\n  <p>The film itself is 393 lines written against nothing but that public API — a title\nscreen, a camera move, five bursts of footage, a pull-up naming one of them. Nothing in\nthe crate underneath it knows what a map or a Pokémon is; every map rectangle and\nclip timestamp lives in that one file, as input.</p>\n\n</section>\n\n<figure aria-labelledby=\"fig-title-cap\">\n  <img src=\"../assets/img/showreel/title-card.png\" alt=\"The opening title card of the rendered film: Pok&eacute;mon Blue's own title screen, framed and bordered on a dark background, with the caption AgentGB - Plays Pokemon! and the line 600 cold boots, one retail cartridge, no save states beneath it.\" />\n  <figcaption id=\"fig-title-cap\">\n    The opening frame. The cartridge's own title screen, captured headlessly and framed by\n    ShowReel — not a picture of one.\n  </figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <h2>The number that mattered</h2>\n\n  <p>The test that answered the risky question: a 120-frame pull-back over the actual 6,832\n× 7,024 atlas, rendered down to 1920 × 1080.</p>\n\n  <div class=\"table-wrap\">\n  <table>\n    <thead>\n      <tr>\n        <th>Approach</th>\n        <th class=\"num\">ms / frame</th>\n        <th class=\"num\">120 frames</th>\n      </tr>\n    </thead>\n    <tbody>\n      <tr><td>Crop and resample from full resolution, one thread</td><td class=\"num\">142.1</td><td class=\"num\">17.05 s</td></tr>\n      <tr><td>Mip pyramid, one thread</td><td class=\"num\">42.2</td><td class=\"num\">5.06 s</td></tr>\n      <tr><td><strong>Mip pyramid, 20 threads</strong></td><td class=\"num\"><strong>4.3</strong></td><td class=\"num\"><strong>0.52 s</strong></td></tr>\n    </tbody>\n  </table>\n</div>\n\n  <p>33× faster than the obvious version, and around 8× faster than real time for\nthe actual shot.</p>\n\n  <p>The reason is choosing an already-shrunk copy of the image before resampling, instead of\nreading the full 48 megapixels on every single frame regardless of how much of it ends\nup on screen. Cost becomes proportional to the output size rather than the source size —\nclose to constant, whatever the zoom. Building that pyramid once, at load, costs 523\nmilliseconds and holds 192MB resident afterward. When the camera pushes in rather than\npulls back — a Game Boy screen blown up to fill the frame — the same code switches to\nnearest-neighbour resampling instead, so the pixel art stays sharp rather than turning\nto mush.</p>\n\n</section>\n\n<figure aria-labelledby=\"fig-pullback-cap\">\n  <img src=\"../assets/img/showreel/pull-back-mid.png\" alt=\"A frame partway through the pull-back: several Kanto towns and routes are visible at once, with a Kanto, entire lower-third caption and a counter reading 226 maps in this picture in the top right corner, over a still-zoomed-in section of the full atlas.\" />\n  <figcaption id=\"fig-pullback-cap\">\n    Partway through the nine-second move — the camera is well off its 1:1 opening on\n    Pallet Town, still short of the whole atlas.\n  </figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <h2>Where it actually happened</h2>\n\n  <p>The whole opening chain — leaving the bedroom, the rival battle, out of the lab, north\nup Route 1 — happens within a few hundred pixels of Pallet Town. On a picture of the\nwhole region, that is a few dozen screen pixels. Every burst in the finished film\nclusters there, because that is where the footage covers, not because the film is\nchoosing to.</p>\n\n  <p>So each clip sits at the edge of the frame instead, and a line is drawn back to the map\ncoordinate it actually happened at.</p>\n\n  <div class=\"pullquote\">\n  <p>&ldquo;The line is the claim, not the position.&rdquo;</p>\n  <cite>What the footage placements are allowed to say</cite>\n</div>\n\n</section>\n\n<figure aria-labelledby=\"fig-bursts-cap\">\n  <img src=\"../assets/img/showreel/bursts.png\" alt=\"The whole Kanto map dimmed, with three video insets bordered in white showing real cold-boot footage, each connected by a thin line to a labelled point on the map: Pallet Town, Oak's Lab with a Charmander battle mid-turn, and a third clip near a route entrance. A counter in the top right reads 584 runs finished.\" />\n  <figcaption id=\"fig-bursts-cap\">\n    Three clips live at once, each on its own line back to the map. The Oak's Lab inset is\n    mid-battle: Charmander using Scratch, a frame out of a real cold boot on the retail\n    cartridge.\n  </figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <h2>What it doesn't do</h2>\n\n  <p>There's no audio — every encode ShowReel produces drops the input track outright. Memory\nis spent on footage, not on the picture: the finished film holds over a gigabyte of\ndecoded video clips in memory at once, about six times what the 48-megapixel atlas\nitself costs once it's been reduced to its pyramid.</p>\n\n  <p>There's no scrubbable preview player either, the thing Remotion's own docs lean on\nhardest. In its place: a single frame in about a tenth of a second, a whole labelled\ncontact sheet of the film in three seconds, and a genuinely scaled-down preview pass in\nunder seven — all well short of the 25 seconds a full render takes. That loop is what\ncaught a caption running off the edge of the frame before a single second of video was\never encoded.</p>\n\n</section>\n",
      "date_published": "2026-08-27T00:00:00+00:00"
    },
    {
      "id": "https://alchemy86.github.io/devlog/posts/the-ledge-in-viridian-city.html",
      "url": "https://alchemy86.github.io/devlog/posts/the-ledge-in-viridian-city.html",
      "title": "The ledge in Viridian City",
      "summary": "Seventeen runs of six hundred died on the same row of the same town. A flood fill said the tile was reachable, and the flood fill was right.",
      "content_html": "<section class=\"prose\">\n\n  <p>A flood fill says (29,26) is fine. There is a 13-step path back to it crossing no warp\ntile. It reports nothing.</p>\n\n  <p>Two things had to be modelled exactly before any check could catch it.</p>\n\n  <p><strong>The ledge.</strong> Stepping down off row 26 does not land on row 27. It jumps to row 28. And\nthe one-wayness is in the cartridge's own data — eight ledge entries, for facing down,\nleft and right, and none for up.</p>\n\n  <p><strong>The walker.</strong> A greedy waypoint walker is not a path-finder. Below a one-way ledge it\nslides along the wall, which is precisely what the 17 failing runs did.</p>\n\n  <figure class=\"code\">\n  <pre><code>          0123456789012345678901234567890123456789\n  y=25    ####....######........#.##..........####\n  y=26    ####....######......................####   &lt;- the waypoint was (29,26)\n  y=27    ###############.###.####################   &lt;- ledge; gaps only at x=15, 19\n  y=28    ...#................................####   &lt;- where 17 runs slid, x=26..32\n  y=29    ...#.................#..............####\n  y=30    ...#................................####\n\n(29,26) walkable=True   step down -&gt; (29,28)     a two-tile jump over row 27\n(29,28) walkable=True   step up   -&gt; None        nothing comes back\nLedgeTiles: 8 entries, facings down/left/right, none for up\n\nGoTo simulated below the ledge, target (29,26):\n  from (29,28) -&gt; stops at (32,28)\n  from (30,28) -&gt; stops at (27,28)\n  from (26,28) -&gt; stops at (31,28)</code></pre>\n  <figcaption>\n    Viridian City rows 25–30, read off the retail cartridge with no emulator run at\n    all — and the failure reproduced from it in three lines. Where the walker stops\n    is exactly the x=26…32 slide the 600-attempt corpus reported.\n  </figcaption>\n</figure>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>The repair is not a bigger budget</h2>\n\n  <p>The row the mart door opens onto crosses the city cleanly, sits six rows above the\nledge, and the rest of the chain finishes even from below the ledge. So the leg turns\nwest first, and an overshoot costs nothing.</p>\n\n  <p>This shape has now appeared three times, which is what makes it a rule rather than three\nanecdotes:</p>\n\n  <div class=\"pullquote\">\n  <p>\n    A waypoint whose overshoot is unrecoverable is a waypoint pointing at a trap.\n    Prefer the turning point with slack around it.\n  </p>\n</div>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>The tool that checks it over-reports, on purpose</h2>\n\n  <p>It cannot know whether an overshoot is reachable — that needs the map's people, and a\nperson in the way is what pushed the walker over the ledge in the first place — and it\nhas no model of the driver's stuck-sidestep. So it is a design aid, not a gate, and it\nsays so.</p>\n\n</section>\n",
      "date_published": "2026-08-27T00:00:00+00:00"
    },
    {
      "id": "https://alchemy86.github.io/devlog/posts/the-label-bug-in-oaks-lab.html",
      "url": "https://alchemy86.github.io/devlog/posts/the-label-bug-in-oaks-lab.html",
      "title": "293 runs stopped on the same text box",
      "summary": "A nine-link chain collapsed from 300 of 300 to 7. The student was doing exactly what its supervisor had told it to do.",
      "content_html": "<section class=\"prose\">\n\n  <p>Oak's Lab, tile (5,3), the message <em>\"Gramps! What about me?\"</em> — the student pressing a\ndirection at an open text box for 400 decisions out of 400 without moving a single tile.</p>\n\n  <p>That specificity is the useful part. A perception failure scatters. A student that fails\n293 times in one room, on one tile, on one message, is not confused about what it is\nseeing.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>The bug was in the teacher</h2>\n\n  <p>Every teacher in the repository answers an open text box with <code class=\"language-plaintext highlighter-rouge\">B</code>. Except the navigation\nteacher, which gated that rule on a mode flag — and that flag reads \"overworld\" while a\nbox is on the screen.</p>\n\n  <p>For five links nothing noticed, because no navigation link had ever been in a room with\na conversation in it. The link that leaves the lab is the first. It put thousands of\nframes of an open text box into the corpus <em>labelled with a direction</em>.</p>\n\n  <p>A direction press re-triggers the box. The student learned that faithfully and did it\nfour hundred times.</p>\n\n  <div class=\"pullquote\">\n  <p>\n    The picture was fine. The student did exactly what its supervisor said. It was a\n    label bug, not a perception bug.\n  </p>\n</div>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>Measuring the blast radius</h2>\n\n  <p>The fix is one shared helper. The interesting question was how much else the bug had\npoisoned: 12.84% label drift on the link that leaves the lab, and 1.43–3.63% on the four\nother navigation links.</p>\n\n  <p>Both the before and the after are published, because the after is not legible without\nthe before.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>Which weights these numbers belong to</h2>\n\n  <p>The 7-of-300 and 300-of-300 figures belong to an earlier, uncommitted arm of the student\nwhich always took Charmander. They are a before-and-after on one training arm, which is\nwhat they are, and not a score for the file that ships. The shipped student's own rates\nare on the <a href=\"../projects/agentgb.html\">project page</a>.</p>\n\n</section>\n",
      "date_published": "2026-08-27T00:00:00+00:00"
    },
    {
      "id": "https://alchemy86.github.io/devlog/posts/the-doubling-back-wall.html",
      "url": "https://alchemy86.github.io/devlog/posts/the-doubling-back-wall.html",
      "title": "The wall you hit walking home",
      "summary": "An agent that learns the way to the shop perfectly cannot learn the way back, because the tiles are identical and the answer is opposite. Two numbers that sum to a hundred prove it is impossible, not merely hard — and the fix was to stop looking in the bag and read what the game already says out loud.",
      "content_html": "<section class=\"prose\">\n\n  <h2>Two numbers that sum to a hundred</h2>\n\n  <p>The route this agent is learning goes out and comes back. Pallet Town, up Route 1, into\nViridian City, into the Mart to collect Oak's parcel — and then the same ground again in\nreverse, all the way home to Oak's lab. Viridian City and Route 1 are each crossed\ntwice, and from almost every tile in them the two crossings want <em>opposite</em> directions.</p>\n\n  <p>A single student trained over both directions of Viridian City scores <strong>33.53%</strong> on one\ntask and <strong>66.77%</strong> on the other. Those two numbers are not a pair of disappointing\nresults. They sum to a hundred, and that is the signature of a partition: from any given\nstart the shared student walks one way or the other, and whichever it picks, exactly one\nof the two tasks is satisfied. There is no third outcome and no middle ground.</p>\n\n  <div class=\"callout\">\n  <p class=\"eyebrow\">Why that number shape matters</p>\n  <p>\n    A policy scoring 40% and 45% is doing something imperfectly. A policy scoring\n    33.53% and 66.77% is doing something <em>perfectly</em> — it is just answering a\n    different question than the one being asked. When two rates in a supposedly\n    independent pair add to one, stop tuning and go and find out what the model\n    cannot see.\n  </p>\n</div>\n\n</section>\n\n<figure class=\"scrollfig\" aria-labelledby=\"fig-route-cap\">\n  <svg viewBox=\"0 0 720 286\" role=\"img\" xmlns=\"http://www.w3.org/2000/svg\" font-family=\"'JetBrains Mono', monospace\">\n    <style>\n      .nd  { fill: var(--code-bg); stroke: var(--hairline); stroke-width: 1.5; }\n      .nd.a{ fill: var(--card); stroke: var(--accent); stroke-width: 2; }\n      .nt  { fill: var(--ink); font-size: 13px; font-weight: 700; }\n      .ns  { fill: var(--ink-soft); font-size: 10px; }\n      .ns.a{ fill: var(--accent); font-weight: 700; }\n      .lnk { stroke: var(--hairline); stroke-width: 2; }\n      .out { stroke: var(--accent); stroke-width: 2; fill: none; }\n      .ret { stroke: var(--ink-soft); stroke-width: 2; fill: none; }\n      .lo  { fill: var(--accent); font-size: 10.5px; font-weight: 700; letter-spacing: .1em; }\n      .lr  { fill: var(--ink-soft); font-size: 10.5px; font-weight: 700; letter-spacing: .1em; }\n      .amb { fill: var(--accent); font-size: 10.5px; font-weight: 700; }\n    </style>\n    <defs>\n      <marker id=\"ao\" markerWidth=\"9\" markerHeight=\"9\" refX=\"8\" refY=\"4.5\" orient=\"auto\">\n        <path d=\"M0,0 L9,4.5 L0,9 z\" fill=\"var(--accent)\" />\n      </marker>\n      <marker id=\"ar\" markerWidth=\"9\" markerHeight=\"9\" refX=\"8\" refY=\"4.5\" orient=\"auto\">\n        <path d=\"M0,0 L9,4.5 L0,9 z\" fill=\"var(--ink-soft)\" />\n      </marker>\n    </defs>\n    <line x1=\"157.0\" y1=\"143.0\" x2=\"189.7\" y2=\"143.0\" class=\"lnk\" />\n    <line x1=\"343.7\" y1=\"143.0\" x2=\"376.3\" y2=\"143.0\" class=\"lnk\" />\n    <line x1=\"530.3\" y1=\"143.0\" x2=\"563.0\" y2=\"143.0\" class=\"lnk\" />\n    <rect x=\"3.0\" y=\"110\" width=\"154\" height=\"66\" rx=\"8\" class=\"nd\" />\n    <text x=\"80.0\" y=\"138\" text-anchor=\"middle\" class=\"nt\">Oak's Lab</text>\n    <text x=\"80.0\" y=\"156\" text-anchor=\"middle\" class=\"ns\">Pallet Town</text>\n    <rect x=\"189.7\" y=\"110\" width=\"154\" height=\"66\" rx=\"8\" class=\"nd a\" />\n    <text x=\"266.7\" y=\"138\" text-anchor=\"middle\" class=\"nt\">Route 1</text>\n    <text x=\"266.7\" y=\"156\" text-anchor=\"middle\" class=\"ns a\">crossed twice</text>\n    <rect x=\"376.3\" y=\"110\" width=\"154\" height=\"66\" rx=\"8\" class=\"nd a\" />\n    <text x=\"453.3\" y=\"138\" text-anchor=\"middle\" class=\"nt\">Viridian City</text>\n    <text x=\"453.3\" y=\"156\" text-anchor=\"middle\" class=\"ns a\">crossed twice</text>\n    <rect x=\"563.0\" y=\"110\" width=\"154\" height=\"66\" rx=\"8\" class=\"nd\" />\n    <text x=\"640.0\" y=\"138\" text-anchor=\"middle\" class=\"nt\">Viridian Mart</text>\n    <text x=\"640.0\" y=\"156\" text-anchor=\"middle\" class=\"ns\">the parcel</text>\n    <text x=\"3\" y=\"20\" class=\"lo\">OUTBOUND — GO AND FETCH OAK&#8217;S PARCEL</text>\n    <path d=\"M80.0,102 L80.0,66 L640.0,66 L640.0,99\" class=\"out\" marker-end=\"url(#ao)\" />\n    <text x=\"3\" y=\"280\" class=\"lr\">RETURN — CARRY IT BACK TO OAK, OVER THE SAME GROUND</text>\n    <path d=\"M640.0,184 L640.0,220 L80.0,220 L80.0,187\" class=\"ret\" marker-end=\"url(#ar)\" />\n    <text x=\"360.0\" y=\"96\" text-anchor=\"middle\" class=\"amb\">same tiles, opposite answer</text>\n  </svg>        <figcaption id=\"fig-route-cap\">\n    The two rooms in amber are walked twice, in opposite directions. A policy that\n    sees only the overworld screen meets the identical picture on both passes and has\n    no basis on which to answer differently — the thing that distinguishes them is a\n    parcel in the bag, and the bag is not drawn on the overworld.\n  </figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <h2>Why no amount of training fixes it</h2>\n\n  <p>What tells the two crossings apart is <code class=\"language-plaintext highlighter-rouge\">OAK's PARCEL</code> sitting in the inventory. The\ninventory is not drawn on the overworld screen. This agent reads a 4 × 36 × 40 picture\nand nothing else — no coordinates, no map register, no memory read of any kind — so the\ninput on the way out and the input on the way back are, for practical purposes, the same\ninput.</p>\n\n  <p>A function cannot return two different values for the same argument. This is not a\ncapacity problem that a wider network or another thousand epochs reaches; it is a\nstatement about what is representable. The 33.53/66.77 split is that statement,\nmeasured.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>The first fix worked, and was abandoned anyway</h2>\n\n  <p>The obvious answer is to go and look. Gen 1 <em>does</em> draw the bag's contents, and the two\nstates are visibly different — <code class=\"language-plaintext highlighter-rouge\">▶OAK's PARCEL / CANCEL</code> with it, <code class=\"language-plaintext highlighter-rouge\">▶CANCEL</code> alone\nwithout. So the first design gave the agent a seventh button, taught it to open the bag,\nread it, close it, and only then decide which way to walk.</p>\n\n  <p>It was built, trained, and smoke-tested successfully. A real certification run put the\nharder of the two rooms at 5/5 and then 299/300. It genuinely worked.</p>\n\n</section>\n\n<figure class=\"pixel\" aria-labelledby=\"fig-bag-cap\">\n  <img src=\"../assets/img/agentgb/bag-parcel-structural.png\" alt=\"Four panels. Top row: two real 160 by 144 Game Boy screens of the item bag, one reading CANCEL alone and one reading OAK's PARCEL above CANCEL. Middle row: the same two screens as the coarse 40 by 36 arrays the network actually receives. Bottom: a difference map of those two arrays, mostly black with a small red band where the extra menu row sits.\" />\n  <figcaption id=\"fig-bag-cap\">\n    <strong>The abandoned approach, and why it was tempting.</strong> The two bag states\n    really are distinguishable in what the network receives — 57 of 1,440 cells differ,\n    4.0% of the observation. The middle row is the literal array handed to the policy,\n    not a re-render of the screen above it.\n  </figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <p>It was thrown away on the captain's correction, and the reason is the interesting part.\nThe game <em>already announces</em> that the parcel has been collected, in plain unmissable\ntext, at the exact frame the milestone fires:</p>\n\n  <div class=\"pullquote\">\n  <p>“BLUE got OAK's PARCEL!”</p>\n  <cite>The cartridge, saying the quiet part out loud</cite>\n</div>\n\n  <p>Building a seventh button, a bag-opening sequence, and an\non-the-way-in-versus-on-the-way-out disambiguation at an identical menu picture was\nsolving a problem the cartridge had already solved — one layer further from the screen\nthan necessary. The bag check was not wrong in the sense of not working. It was wrong in\nthe sense of reaching <em>past</em> an answer already sitting in plain text to go digging for a\nsecond, harder copy of the same fact.</p>\n\n</section>\n\n<figure class=\"pixel narrow\" aria-labelledby=\"fig-parcel-cap\">\n  <img src=\"../assets/img/agentgb/mgba-collect-oaks-parcel.png\" alt=\"A Game Boy screenshot of the Viridian Mart interior with the player standing at the counter and a dialogue box drawing at the bottom of the screen, captioned as the collect-oaks-parcel milestone at decision 578 on the mGBA libretro core, seed 0.\" />\n  <figcaption id=\"fig-parcel-cap\">\n    The frame the cartridge set the <code>collect-oaks-parcel</code> milestone byte, on\n    a genuine cold power-on — captured on mGBA's libretro core rather than our own\n    emulator, seed 0, decision 578. The dialogue box is mid-draw here; the announcement\n    text lands in the frames immediately after.\n  </figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <h2>The pattern that came out of it</h2>\n\n  <p>Once you look for it, the shape is everywhere in this route: <strong>every goal in the chain\nends with the cartridge announcing, in unique on-screen text, that it is done — and that\nannouncement is the trigger for the next goal.</strong> A recogniser per announcement, a\ntrained behaviour per goal, chained in order.</p>\n\n  <p>Nothing is deduced, nothing is inspected, nothing is hard-coded. The driver that\nimplements this knows nothing about parcels, Oak, or any specific room; declaring a new\nstage is a longer list in a data file, never a change to the code.</p>\n\n  <p>Two design details are worth pulling out, because they are the whole difference between\nthis and the interrupt mechanism the project already had:</p>\n\n</section>\n\n<div class=\"cards\">\n  <div class=\"card\">\n    <div class=\"card-hd\">\n      <p class=\"kicker\">A latch, not a check</p>\n      <h3>The trigger screen is gone within a handful of frames</h3>\n    </div>\n    <div class=\"card-bd\">\n      <p>\n        A per-decision recogniser — the kind that hands control back the instant its\n        screen disappears — would see the announcement once and forget it on the very\n        next decision. That is useless for a fact which, once true, stays true for the\n        rest of the episode.\n      </p>\n      <p>\n        So the stage is <em>latched</em>: a single integer held across the episode,\n        advanced once, never re-checked. Once a stage fires, every earlier recogniser\n        is never consulted again, and the route itself has changed — this is not a\n        momentary interruption of some other goal.\n      </p>\n    </div>\n  </div>\n  <div class=\"card\">\n    <div class=\"card-hd\">\n      <p class=\"kicker\">A nudge, not a retrain</p>\n      <h3>The base network is proven byte-identical before and after</h3>\n    </div>\n    <div class=\"card-bd\">\n      <p>\n        The behaviour each stage latches is a small separate head nudging a\n        <em>frozen</em> base policy, at its original six-action width — no seventh\n        button, no padding. Five links share one pooled adapter rather than five\n        separate ones, which keeps peak memory during training well under 5 GB against\n        a 20 GB ceiling that had cancelled a full retrain.\n      </p>\n      <p>\n        The base weights are hashed before training and after, and the hash is required\n        to match. A fix that quietly moved the thing it was meant to leave alone would\n        not be a fix.\n      </p>\n    </div>\n  </div>\n</div>\n\n<section class=\"prose\">\n\n  <h2>The trigger did not need a crop, and that was checked first</h2>\n\n  <p>Another recogniser in this project keys on a nickname prompt and needs a deliberate\ncrop, to hide a species name a wider view would let it cheat on. This one takes the full\nobservation, because the parcel announcement is not a screen that could plausibly be\nconfused with anything else in the game.</p>\n\n  <p>That was verified before a recogniser was trained rather than assumed after. Playing the\nscripted teacher through the collection and recording the on-screen text at every\ndecision found the exact string and the exact decision it appears on. Then the last\nrecorded frame of successful episodes — from a 1,500-episode corpus whose episode\nlengths range from 13 to 34 decisions — was compared against a fresh live capture of\nthat screen: <strong>byte-for-byte identical, zero difference, on every one of five\nspot-checked episodes of very different lengths</strong>.</p>\n\n  <p>The reason it is identical is structural rather than lucky. The dialogue box is opaque,\nand the success flag fires at a fixed point in the game's own script no matter which\nbutton got the player there. That is what makes \"the last frame of a successful episode\"\na correct way to harvest training positives without any per-frame text matching at all.</p>\n\n  <p>The shipped recogniser scores <strong>99.93%</strong> held-out accuracy and 99.96% balanced accuracy,\ntrained on 1,500 positives against 6,000 negatives sampled from six other links' own\ncorpora.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>What it measured</h2>\n\n  <p>Each of the five return-leg links certified on its own, with the adapter applied\nunconditionally, sampled at temperature 1.0, N=300 — alongside two floors, because a\nrate with nothing under it is not evidence:</p>\n\n  <div class=\"table-wrap\">\n  <table>\n    <thead>\n      <tr>\n        <th>Link</th>\n        <th class=\"num\">Success</th>\n        <th class=\"num\">Random floor</th>\n        <th class=\"num\">Press-A floor</th>\n      </tr>\n    </thead>\n    <tbody>\n      <tr><td class=\"mono\">out-of-the-mart</td><td class=\"num\">300 / 300 = 100.00%</td><td class=\"num\">34.80%</td><td class=\"num\">0.00%</td></tr>\n      <tr><td class=\"mono\"><strong>south-out-of-viridian</strong></td><td class=\"num\"><strong>300 / 300 = 100.00%</strong></td><td class=\"num\">3.40%</td><td class=\"num\">0.00%</td></tr>\n      <tr><td class=\"mono\"><strong>back-down-route-1</strong></td><td class=\"num\"><strong>300 / 300 = 100.00%</strong></td><td class=\"num\">1.20%</td><td class=\"num\">0.00%</td></tr>\n      <tr><td class=\"mono\">into-oaks-lab</td><td class=\"num\">294 / 300 = 98.00%</td><td class=\"num\">4.00%</td><td class=\"num\">0.00%</td></tr>\n      <tr><td class=\"mono\">receive-the-pokedex</td><td class=\"num\">221 / 300 = 73.67%</td><td class=\"num\">6.40%</td><td class=\"num\">0.00%</td></tr>\n    </tbody>\n  </table>\n</div>\n\n  <p>The two rows in bold are the doubling-back rooms — the entire reason the work exists.\nBoth certify at 100.00%, against random floors of 3.40% and 1.20%. The mechanism\nresolves an ambiguity that a memoryless, unconditioned student <em>provably</em> could not.</p>\n\n  <p>N=300, not this project's usual 3,000. Three hundred clean attempts bound a failure rate\nnear 1% by the rule of three.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>And then the honest part</h2>\n\n  <p>The first full sixteen-link cold-boot swarm, with everything wired in, reached the last\nlink before the parcel is delivered — and scored <strong>0 of 26</strong> on it.</p>\n\n  <p>Not 60%. Zero. Fifteen of sixteen milestones at 100%, both hard rooms perfect, and the\nlast one a complete failure.</p>\n\n  <p>It was worth having, because it was specific. The 73.67% above was the same weakness\nmeasured in isolation, and the chain's own actual entry tile evidently sits on the\nunlucky side of it consistently enough that no draw of 26 clears it. Isolated replay\nshowed the failure precisely: the adapter reproduces the teacher's first eight moves\nexactly — <code class=\"language-plaintext highlighter-rouge\">left</code>, then seven <code class=\"language-plaintext highlighter-rouge\">up</code>s — and then, at the one decision the teacher turns\n<code class=\"language-plaintext highlighter-rouge\">right</code> toward Oak, presses <code class=\"language-plaintext highlighter-rouge\">down</code> and oscillates <code class=\"language-plaintext highlighter-rouge\">up</code>/<code class=\"language-plaintext highlighter-rouge\">down</code> at that junction for the\nrest of its budget.</p>\n\n  <p>A second training draw with more epochs and a larger sampled corpus produced the\n<em>identical</em> failure at the <em>identical</em> junction. Not seed noise — stable across\nindependent draws, which is its own finding: this project has now found three times that\n\"more epochs\" is not an answer to a genuinely blind tile.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>The mechanism suspected, half confirmed and half refuted</h2>\n\n  <p>The plausible story was that the frozen base holds a confident, actively <em>wrong</em> prior\nat that tile — it shares its room with several links the base <em>was</em> trained on — so the\nadapter has to overturn a strong opinion rather than fill an empty one.</p>\n\n  <p>Measured directly at the stuck tile, that half is true: the base reads <strong>96.3–97.7%\n<code class=\"language-plaintext highlighter-rouge\">down</code></strong> — the wrong answer — under every trained goal id.</p>\n\n  <p>The proposed <em>fix</em>, though, was refuted rather than left untested. Feeding the untrained\nneutral conditioning row instead of the usual one gives 96.3% <code class=\"language-plaintext highlighter-rouge\">down</code>, statistically\nindistinguishable from what it replaced. The identity transform passes features through\nunmodified, but the action head was never trained on unconditioned features in isolation\n— so an \"untrained\" row is not the same thing as an \"unbiased\" one. That is a\ndistinction worth carrying out of here.</p>\n\n  <p>One id <em>is</em> measurably different, reading 61.3% <code class=\"language-plaintext highlighter-rouge\">right</code> / 38.7% <code class=\"language-plaintext highlighter-rouge\">down</code> — not confidently\ncorrect, but the only one whose prior does not actively fight the right answer.\nRetraining against it is the next thing worth trying, and it was deliberately not tried\nhere: that id's semantics for this checkpoint are not established, and changing it risks\nfour links in the same stage that already work.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>Where it ended up</h2>\n\n  <p>The last link was closed in a later round — a fresh corpus for the conversation half of\nit, a dedicated goal for the press that <em>starts</em> the conversation (the base gets that\nright only 4.55% of the time unaided), a battle policy on the return crossing of Route 1\nchanged from flee to fight-or-flee after a real seed was traced into an infinite\nbattle-menu deadlock, and two purpose-built start states so the corpora were not all the\nsame starter.</p>\n\n  <p>Cold boot, N=150, sampled, the whole sixteen-link chain: <strong>145/150 = 96.67%</strong>\n[92.4–98.6%]. Per starter — the standing rule now — <strong>Bulbasaur 87/90, Charmander 13/13,\nSquirtle 45/47</strong>, no starter anywhere near zero and all three intervals overlapping\nheavily.</p>\n\n  <p>One more result belongs here because it is the most useful kind. Running the same\ncommand <em>without</em> the already-shipped interrupt adapters gives a much worse 13/26 — and\nevery one of those twelve extra failures is a known trap six links earlier, nothing to\ndo with the return leg at all. A chain-level number only means what it claims once every\nalready-fixed piece is actually wired in.</p>\n\n</section>\n",
      "date_published": "2026-08-27T00:00:00+00:00"
    },
    {
      "id": "https://alchemy86.github.io/devlog/posts/the-door-rule.html",
      "url": "https://alchemy86.github.io/devlog/posts/the-door-rule.html",
      "title": "The door rule",
      "summary": "The cartridge says where outdoor maps go and says nothing at all about interiors. Placing 190 rooms is a decision, and it was settled by measurement.",
      "content_html": "<section class=\"prose\">\n\n  <h2>Outdoors is the cartridge's</h2>\n\n  <p>The 36 connected maps go where the connection records put them. Exact arithmetic, no\nsearch: a connection record names one block twice — once in the neighbour's block data,\nonce where the engine copies it — and one block in two frames is an exact offset.</p>\n\n  <p>Every chain of connections that arrives at a map puts it in the same place. Zero\nplacement disagreements.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>Indoors is a decision, but the door is not</h2>\n\n  <p>An interior has no connections at all. The cartridge says which door leads to it and\nnothing about where the room is. So the rule is one sentence: a building is drawn\nadjacent to the map its door is in, on the side that door is on, in line with it.</p>\n\n  <p>What follows from that took several rounds, and the way to compare them is the\nroom-to-door distance over the rooms every layout can measure:</p>\n\n  <div class=\"table-wrap\">\n  <table>\n    <thead>\n      <tr><th>Layout revision</th><th class=\"num\">Door distance mean / median</th><th class=\"num\">Nearer another region's door</th><th class=\"num\">Out of door order</th></tr>\n    </thead>\n    <tbody>\n      <tr><td>Before the whole-map review</td><td class=\"num\">715 / 456 px</td><td class=\"num\">92 of 169</td><td class=\"num\">16 of 71</td></tr>\n      <tr><td>After it</td><td class=\"num\">599 / 383 px</td><td class=\"num\">85 of 184</td><td class=\"num\">—</td></tr>\n      <tr><td>After three reported faults</td><td class=\"num\">503 / 350 px</td><td class=\"num\">79 of 184</td><td class=\"num\">—</td></tr>\n      <tr><td>Doors' order as the primary key</td><td class=\"num\"><strong>494 / 305 px</strong></td><td class=\"num\"><strong>72 of 184</strong></td><td class=\"num\"><strong>0 of 71</strong></td></tr>\n    </tbody>\n  </table>\n</div>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>Ordering has to outrank nearness, and the weight was measured</h2>\n\n  <p>Two buildings whose street doors are on the same side of the same town must be drawn in\nthe doors' own order along that side. Added as an ordinary term in the distance cost,\nthat loses every time: an inversion the eye reads at a glance is worth only a few pixels\nof nearness, and a building will buy the pixels. Which is how Cinnabar's gym came to be\ndrawn below the two shops whose doors are eight tiles below its own.</p>\n\n  <p>At weight 4 the cartridge still has five pairs the wrong way round. At 8 it has none.\nFrom 8 to 16 the layout does not move at all.</p>\n\n  <p>And \"not the wrong way round\" turned out to be a loophole the search will find. With\nequality free, seven pairs came to rest exactly level — Saffron's gym and mart among\nthem, the very pair that was complained about. Making the ordering strict cost nothing:\nsame mean, same median, same sheet.</p>\n\n</section>\n\n<figure class=\"pixel narrow\" style=\"margin-inline:auto;\">\n  <img src=\"../assets/img/pixelgb/pallet-town-2x.png\" width=\"640\" height=\"576\" alt=\"Pallet Town rendered at 2x scale: a small Game Boy town with two houses, a laboratory, water to the south and a path north.\" />\n  <figcaption>\n    Pallet Town, the worked example. Red's house at tile (5,5) files left; Blue's at\n    (13,5) and Oak's lab at (12,11) file right, with Blue's house above the lab because\n    its door is six tiles above the lab's. The community's hand-authored atlas puts\n    those four panels on those same two sides in that same order, which is independent\n    confirmation of the rule and not its source.\n  </figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <h2>One warp in the cartridge is not a door</h2>\n\n  <p>Celadon City's ninth warp, tile (39,19), drops you into map 136 — the department store's\nfifth floor. That floor's own three warps lead to the roof, the fourth floor and the\nlift; none of them leads back to the street. Read as a street door, it filed one floor\nof the store 254 tiles from the other six, on the opposite side of the city.</p>\n\n  <p>So an outdoor warp counts as the way in only when the room it reaches has a warp back to\nthe map you came from. Map 136 is the only map in the cartridge that fails that test,\nand with the rule in place the store lands as one column of seven.</p>\n\n  <p>Victory Road looks like the same bug and is not. Route 23 has two street doors of its\nown, into 1F and into 2F, and both rooms walk back out. The route is 20 tiles wide, so\nthose doors are genuinely on opposite sides of it and the two halves file either side.\nThe community's hand-authored atlas bundles them; the cartridge does not, and the\ncartridge wins.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>A building that will not fit comes apart at one of its own doors</h2>\n\n  <p>The S.S. Anne is entered through Vermilion's dock rather than off the street, so the\ndock, the ship and its eleven rooms are one building. A twelve-room block wants about a\nmillion square pixels of one rectangle, and that does not exist within two screens of\nVermilion. Every arrangement of it as one block put it beyond Route 12, further from its\nown town than anything else in the cartridge.</p>\n\n  <p>It was not mis-assigned and the search was not failing. Measured against the finished\nsheet, where it stood was the nearest place a single rectangle of that size would go.</p>\n\n  <p>So a building may be cut at one of its rooms, and the rooms behind that door become a\nwing, placed by the same rule with \"the map\" now meaning a room of its own building.</p>\n\n  <p>What is not negotiable through any of that: a panel never covers walkable world or\nanother panel. The finished rectangles are checked and an intersection fails the render.\nThat assertion is worth more than the rule it guards, because it is what makes the next\nchange to the layout safe.</p>\n\n</section>\n",
      "date_published": "2026-08-27T00:00:00+00:00"
    },
    {
      "id": "https://alchemy86.github.io/devlog/posts/the-day-that-added-nothing.html",
      "url": "https://alchemy86.github.io/devlog/posts/the-day-that-added-nothing.html",
      "title": "The day that added nothing",
      "summary": "Five identical training runs, a 23-point spread, and two published numbers that turned out not to be readable.",
      "content_html": "<section class=\"prose\">\n\n  <h2>The training run is the largest term, and it had no control</h2>\n\n  <p>Five runs of the identical configuration on one link scored:</p>\n\n  <div class=\"table-wrap\">\n  <table>\n    <thead><tr><th>Run of an identical configuration</th><th class=\"num\">1</th><th class=\"num\">2</th><th class=\"num\">3</th><th class=\"num\">4</th><th class=\"num\">5</th></tr></thead>\n    <tbody>\n      <tr><td>Cold success rate</td><td class=\"num\">100.00%</td><td class=\"num\">92.33%</td><td class=\"num\">92.33%</td><td class=\"num\">84.63%</td><td class=\"num\">77.00%</td></tr>\n    </tbody>\n  </table>\n</div>\n\n  <p>A 23-point band, most of it the seed and the rest the BLAS thread count. Every ablation\npublished before that day lacked the control, which means every one of them could have\nbeen measuring the draw rather than the change.</p>\n\n  <p>A fit does not reproduce. Same seed, same recipe, a differently-loaded machine, and you\nget different weights.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>Cold evaluation over a state pool is optimistic by about a factor of two</h2>\n\n  <p>Every state in a start-state pool is frozen from one traversal, so the map's own people\nbarely move between them. Same policy, same tile, 150 attempts: 100% under a 0–96 frame\nstart offset, <strong>52.7% under 0–3,000</strong>.</p>\n\n  <p>Six distinct people-layouts against twenty-two. That is the whole difference.</p>\n\n  <p>Every rate published since carries both spreads. The gap between them is the measure of\nhow brittle a student is.</p>\n\n  <div class=\"pullquote\">\n  <p>\n    A person standing in the way is drawn on the screen. The screen-only student pays\n    nothing measurable for the wider spread; the feature-vector student it replaced\n    halved.\n  </p>\n</div>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>Then the naming rule</h2>\n\n  <p>On 21 August, in one evening, this project reported a rate to the captain as belonging\nto the committed network when it did not — twice. Once because a results page never\nnamed which weights produced its headline. Once because a sampling result measured on\none student was carried onto a different one.</p>\n\n  <p>Both reports were plausible, both were wrong, and nothing in the repository could have\ncaught either.</p>\n\n  <p>The fix is a check that fails a build the same way it failed the captain. A page opts in\nwith a marker in its first forty lines. Every table on an opted-in page that contains a\npercentage-looking cell must carry one of: a per-row attribution column, a weights\nfilename in its rows, or the literal word <code class=\"language-plaintext highlighter-rouge\">unattributed</code>.</p>\n\n  <p>The opt-in matters. Most tables in the repository are about the teacher — a scripted\nprogram, never versioned by weights — or about cartridge mechanics. Neither has this\nambiguity.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>And the checker passed for the wrong reason</h2>\n\n  <p>An early version carried a sticky \"have we seen a model name anywhere in this file yet\"\nflag. A single mention in a page's opening paragraph made every table below it\nunfailable, no matter how far below and no matter what it was about.</p>\n\n  <p>It was caught by deleting a real table's attribution column and watching the check still\npass. Each table is now judged on its own.</p>\n\n  <div class=\"pullquote\">\n  <p>\n    A rate with no model name attached is not a verified rate.\n  </p>\n  <cite>The rule this repository keeps</cite>\n</div>\n\n</section>\n",
      "date_published": "2026-08-27T00:00:00+00:00"
    },
    {
      "id": "https://alchemy86.github.io/devlog/posts/tackle-is-95-per-cent.html",
      "url": "https://alchemy86.github.io/devlog/posts/tackle-is-95-per-cent.html",
      "title": "TACKLE is 95 per cent and we said 94",
      "summary": "Nothing failed. A number had been computed from a belief rather than read from the cartridge, and it sat in four files for as long as they existed.",
      "content_html": "<section class=\"prose\">\n\n  <p>No run was affected — the code was reading the cartridge all along. Only the prose was\nwrong.</p>\n\n  <p>It was found by re-reading the move table while writing a page about discoveries, on the\ngrounds that a page about discoveries which repeats a number without checking it is not\nworth having.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>Read the table, and check the rows nobody disputes first</h2>\n\n  <p>Six bytes per move, straight out of the cartridge:</p>\n\n  <div class=\"table-wrap\">\n  <table>\n    <thead><tr><th>Move</th><th class=\"num\">Id</th><th class=\"num\">Power</th><th class=\"num\">Accuracy byte</th><th class=\"num\">As a percentage</th></tr></thead>\n    <tbody>\n      <tr><td>POUND</td><td class=\"num\">1</td><td class=\"num\">40</td><td class=\"num\">255</td><td class=\"num\">100%</td></tr>\n      <tr><td>SCRATCH</td><td class=\"num\">10</td><td class=\"num\">40</td><td class=\"num\">255</td><td class=\"num\">100%</td></tr>\n      <tr><td>VINE WHIP</td><td class=\"num\">22</td><td class=\"num\">35</td><td class=\"num\">255</td><td class=\"num\">100%</td></tr>\n      <tr><td><strong>TACKLE</strong></td><td class=\"num\">33</td><td class=\"num\">35</td><td class=\"num\"><strong>242</strong></td><td class=\"num\"><strong>94.9%</strong></td></tr>\n      <tr><td>HYPER BEAM</td><td class=\"num\">63</td><td class=\"num\">150</td><td class=\"num\">229</td><td class=\"num\">89.8%</td></tr>\n      <tr><td>HYDRO PUMP</td><td class=\"num\">56</td><td class=\"num\">120</td><td class=\"num\">204</td><td class=\"num\">80.0%</td></tr>\n    </tbody>\n  </table>\n</div>\n\n  <p>Every row but the one under investigation matches the values Generation 1 is known for.\nThat is what says the table is being read at the right offset with the right stride.</p>\n\n  <figure class=\"code\">\n  <pre><code>python3 - \"$ROM\" &lt;&lt;'PY'\nimport sys\nrom = open(sys.argv[1], 'rb').read()\ne = 0x0E * 0x4000 + (33 - 1) * 6   # Moves, 0E:4000, TACKLE is move 33\nprint(\"power %d accuracy %d (%.1f%%)\" % (rom[e+2], rom[e+4], rom[e+4] * 100 / 255))\nPY\n# power 35 accuracy 242 (94.9%)</code></pre>\n  <figcaption>\n    The whole correction, against your own cartridge. No ROM is distributed by the\n    project; you point <code>$ROM</code> at yours.\n  </figcaption>\n</figure>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>Where 240 came from</h2>\n\n  <p>94% of 255 is 239.7, which rounds to 240. It is the byte you get by computing it from a\npercentage you already believed, instead of reading it.</p>\n\n  <div class=\"pullquote\">\n  <p>\n    When you write down a number the cartridge holds, write down the command that\n    reads it.\n  </p>\n</div>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>And the accuracy byte is not the accuracy anyway</h2>\n\n  <p>The hit calculation scales a move's accuracy byte by the attacker's accuracy stage and\nthe inverse of the defender's evasion stage. A policy reading the ROM value is reading a\nnumber that has not been true since the first SAND-ATTACK landed.</p>\n\n  <p>A Pidgey's SAND-ATTACK takes a 95% TACKLE to <strong>62%</strong> and then <strong>47%</strong>. Both ratios come\nout of a stage-modifier table read from the cartridge, located by searching for its own\nopening bytes — a signature that occurs exactly once — and re-checked on every read\nagainst two properties: the first pair must be 0.25, and the middle pair must be exactly\n1:1, because a table read from the wrong place almost never has a neutral stage in its\nmiddle.</p>\n\n  <div class=\"callout\">\n  <p class=\"eyebrow\">Found only at N = 3,000</p>\n  <p>\n    Three of 3,000 attempts at one scenario died in the same shape: at 2 HP against a\n    Pokémon on 1 HP, the driver swung rather than escaped, because a good roll would\n    end it first. Two separate 600-attempt runs were clean. The bug was not rare in\n    the mechanic, it was rare in the route — it needs a Pidgey that has had time to\n    use SAND-ATTACK twice.\n  </p>\n</div>\n\n  <p>There is a second trap underneath it, and the atlas carries its own warning about it: in\nthe stat-stage block, <strong>7 is neutral, not 0</strong>, and the block is zeroed work RAM until\nthe battle-init routine writes the sevens. A sample taken on the first frames of a\nbattle reads 0 everywhere and looks like every stat six stages down.</p>\n\n</section>\n",
      "date_published": "2026-08-27T00:00:00+00:00"
    },
    {
      "id": "https://alchemy86.github.io/devlog/posts/reading-the-screen-without-the-letters.html",
      "url": "https://alchemy86.github.io/devlog/posts/reading-the-screen-without-the-letters.html",
      "title": "Reading the screen without reading the letters",
      "summary": "At 40 by 36 no letterform survives. Six in-game messages are still 97.2% separable — and the first two experiments that said otherwise were both too small.",
      "content_html": "<section class=\"prose\">\n\n  <h2>Two wrong answers first</h2>\n\n  <p>Attempt one tested two message pairs at N=5 and got balanced accuracy 0.50: chance.\nAttempt two sharpened the question and got 0.33: still chance.</p>\n\n  <p>Both were undermined by the same thing. Three to five examples per class lets a probe\npredict one class always and look exactly like chance.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>The answer with real N</h2>\n\n  <p>Dozens of genuine frames per message, taken from the typing animation itself, over six\ndistinct in-game messages. Nearest-centroid across all six identities, with a temporal\nsplit — train on each message's first 65% of typing, test on the last 35% it has never\nseen.</p>\n\n  <p><strong>97.2% accuracy against 20.0% chance</strong>, N=36 held out, permutation p &lt; 0.005. The\nconfusion matrix is essentially the identity matrix.</p>\n\n  <p>What survives is shape, not letters: line length, word-wrap position, letter density per\nregion.</p>\n\n  <p>One of the six messages had to be captured from a separate session, and its background\ndiffers from the other five by 14 of 1,440 cells, all inside one small icon. Removing\nthat message entirely, or masking those 14 cells, moves the headline by about one point.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>The version that mattered in practice</h2>\n\n  <p>Compare the bag opened with an empty item pocket against the same bag holding Oak's\nparcel. <strong>57 cells of the 40×36 observation separate the two states perfectly</strong>, and not\none of them requires reading a letter.</p>\n\n  <p>A goal marker does not have to be legible text. A reliable change in layout is enough.</p>\n\n</section>\n\n<figure class=\"pixel\">\n  <img src=\"../assets/img/agentgb/bag-parcel-structural.png\" width=\"872\" height=\"1284\" alt=\"Three stacked panels: the real 160x144 bag screen, the same screen as a coarse 40x36 observation, and a difference map highlighting the cells that separate an empty item pocket from one holding the parcel.\" />\n  <figcaption>\n    The real screen, the actual observation, and a difference map, for the bag with an\n    empty item pocket against the same bag holding the parcel. The separating cells are\n    a change in layout, not a legible word.\n  </figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <p>These are fresh linear probes and nearest-centroid classifiers fit on frozen\nobservations, not a trained student network, so there is no weights file to name against\nthem.</p>\n\n</section>\n",
      "date_published": "2026-08-27T00:00:00+00:00"
    },
    {
      "id": "https://alchemy86.github.io/devlog/posts/let-go-of-the-d-pad.html",
      "url": "https://alchemy86.github.io/devlog/posts/let-go-of-the-d-pad.html",
      "title": "Let go of the D-pad",
      "summary": "One line took a cartridge map capture from 113 maps to 216. A door is a warp on both sides, and a player still holding the direction walks straight back out.",
      "content_html": "<section class=\"prose\">\n\n  <h2>Getting in at all</h2>\n\n  <p>Writing a map number into <code class=\"language-plaintext highlighter-rouge\">wCurMap</code> crashes the game. The whole map header sits\nunderneath it, so the engine ends up reading the new map's blocks through the old map's\npointers.</p>\n\n  <p>The safe route is <code class=\"language-plaintext highlighter-rouge\">wWarpEntries</code>: redirect one of the current room's own warps at the\ntarget map and walk the player into it. The engine loads the destination header itself —\n<code class=\"language-plaintext highlighter-rouge\">LoadMapHeader</code>, the tileset copy into video RAM, the palette, the objects, the screen.\nEverything after the walk is the game's own.</p>\n\n  <p>So PixelGB plays the opening, saves the machine's state the moment it stands on a real\nmap, and for each of the 226 maps rewinds to that moment, points one warp at the target\nand walks in.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>And then one line was worth a hundred maps</h2>\n\n  <div class=\"pullquote\">\n  <p>\n    Let go of the D-pad the instant the map changes.\n  </p>\n  <cite>The single most important line in <code>warp_to</code></cite>\n</div>\n\n  <p>A door is a warp on both sides. You arrive on the doormat, and a player still holding\nthe direction takes one more step and walks straight back out.</p>\n\n  <p>Holding: 113 maps photographed. Releasing on arrival: 216.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>The one that was stranger: shop clerks talk</h2>\n\n  <p>Several maps put a text box up the moment you arrive, and Generation 1 does that by\nparking the window layer at <code class=\"language-plaintext highlighter-rouge\">WY = 0</code>. Which means the window covers the entire screen\nand the map is drawn through it.</p>\n\n  <p>An earlier version of the comparison excluded \"wherever the window is\", the way it\nexcludes sprites — and so masked the whole picture. 31 maps went from exact to\ninconclusive and two to no-alignment, with nothing in the report to say why.</p>\n\n  <p>The right answer was not to subtract the text box but to dismiss it, the way a player\ndoes: press B until the window is off-screen again, requiring several consecutive clear\nchecks, because the window parks off-screen for a few frames between two boxes of one\nconversation.</p>\n\n  <p>It looked like a tolerance problem and it was a modelling one.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>What it did not rescue</h2>\n\n  <p>The Hall of Fame. Walk in and Oak starts talking, and his script is not one you can\npress B through — it inducts the party. PixelGB presses B up to eighty times and\nrequires four consecutive clear checks before photographing; this one still has a text\nbox up when the budget runs out, so it is counted on its own.</p>\n\n  <p>Ten more maps have nowhere to arrive: a warp names a destination warp on the far side\nand these have none, so the camera comes to rest outside the map. Those and the Hall of\nFame are the eleven named on the <a href=\"../projects/pixelgb.html\">project page</a>.</p>\n\n</section>\n",
      "date_published": "2026-08-27T00:00:00+00:00"
    },
    {
      "id": "https://alchemy86.github.io/devlog/posts/four-bugs-one-line-each.html",
      "url": "https://alchemy86.github.io/devlog/posts/four-bugs-one-line-each.html",
      "title": "Four bugs, one line each",
      "summary": "A dropped field, a RETURNING clause that returns the wrong thing, a bigint that arrived as a string, and a CSS grid that could not get narrower than 16rem.",
      "content_html": "<section class=\"prose\">\n\n  <h2>\"The Pokémon images don't work\"</h2>\n\n  <p>The emulator was sending an offer card — sprite, types, determinant total, a shiny\nprediction — right alongside the Pokémon spec. The offer endpoint read only the spec and\nthe save identity beside it. The card object was arriving on every request and being\ndropped on the floor, so every offer showed the no-picture placeholder.</p>\n\n  <p>The fix came with two rules more interesting than the bug.</p>\n\n  <p>The card's sprite is a base64 PNG, not the collection's raw pixel array, so it is\ndecoded on the way in — indexed or RGB8, non-interlaced — and <strong>the PNG's own header is\nthe authority on geometry</strong>. A declared width that disagrees is a refusal, and\ndecompression runs with an exact output limit so a compression bomb cannot spend memory.</p>\n\n  <p>And a malformed card is dropped field by field, never a 400. An optional decoration from\nthe other side of a shared contract must not turn a valid offer into an error — but the\nreasons ride back on the reply, precisely because the silent version of that is the bug\nabove.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>Every poll looked too fast</h2>\n\n  <p>The device-code login flow enforces a minimum polling interval, and the endpoint has to\nboth read the last poll time and stamp a new one.</p>\n\n  <p>Written the obvious way — one <code class=\"language-plaintext highlighter-rouge\">UPDATE … RETURNING</code> — it silently never works, because\n<code class=\"language-plaintext highlighter-rouge\">RETURNING</code> sees post-update values. The endpoint reads its own new timestamp, computes\nan interval of zero, and interval enforcement quietly does nothing.</p>\n\n  <p>The shape that works reads the previous value under a row lock first and updates in a\nsecond common table expression. It was caught before commit by reading the Postgres\ndocumentation rather than by a test — and there is now a test, so a \"tidy-up\" back to a\nsingle statement turns red.</p>\n\n  <p>The same snapshot rule bites twice more in this codebase: a data-modifying CTE is\ninvisible to the same statement's <code class=\"language-plaintext highlighter-rouge\">SELECT</code>, so the lapsed-sprite purge must run as a\nseparate <code class=\"language-plaintext highlighter-rouge\">UPDATE</code> before the <code class=\"language-plaintext highlighter-rouge\">SELECT</code> that reads the collection, and the rate limiter\ncounts only prior attempts — which is why \"max\" here means allow exactly max, deny the\nmax-plus-first.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>A row id that was a string</h2>\n\n  <p><code class=\"language-plaintext highlighter-rouge\">pg</code> returns 64-bit integers as JavaScript strings by default, because they do not fit\nsafely in a double. Every id in this schema is a <code class=\"language-plaintext highlighter-rouge\">bigint</code>, so <code class=\"language-plaintext highlighter-rouge\">Number.isInteger(id)</code>\nguards silently stopped guarding and ids in JSON quietly became strings. Measured: a\nfriendship id came back as <code class=\"language-plaintext highlighter-rouge\">\"1\"</code>.</p>\n\n  <p>One type-parser registration at the database module fixes it globally.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>A grid that could not shrink</h2>\n\n  <p>The Pokémon cards live in a CSS grid. Written as <code class=\"language-plaintext highlighter-rouge\">repeat(auto-fill, minmax(16rem,\n1fr))</code>, that grid physically cannot get narrower than 16rem — so below about 350 pixels\nit made the whole document wider than the viewport and every panel on the page got\nclipped mid-word at the right edge. The <code class=\"language-plaintext highlighter-rouge\">min(100%, 16rem)</code> spelling is load-bearing, not\nstylistic.</p>\n\n  <p>The same class of fault lived in two other places: the site header, where the brand plus\nthe navigation come to about 350 pixels with no wrapping allowed; and a form label\ninside a card, where a flex item's automatic minimum size is its content width, so a\n16rem minimum on one label spilled the card at every width.</p>\n\n  <p>All three are one mistake — a rule that sets a floor on the page width — and one\nmeasurement catches all of them:</p>\n\n  <figure class=\"code\">\n  <pre><code>for (const el of document.querySelectorAll(\"body *\")) {\n  const r = el.getBoundingClientRect(),\n        p = el.parentElement.getBoundingClientRect();\n  if (r.right &gt; p.right + 1) { /* this element overflows its parent */ }\n}\ndocument.documentElement.scrollWidth &gt; document.documentElement.clientWidth</code></pre>\n  <figcaption>\n    Run at 1440, 1024, 800, 600, 420, 360, 320 and 280 pixels, with the in-card\n    accept form both closed and open. It finds the element that overflows, not just\n    the fact that something does.\n  </figcaption>\n</figure>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>And one that belongs in no category</h2>\n\n  <p><code class=\"language-plaintext highlighter-rouge\">pgrep -f</code> and <code class=\"language-plaintext highlighter-rouge\">pkill -f</code> match the process doing the matching. An automated run on this\nrepository killed itself with a pattern sweep for a dev server, because its own command\nline contained the pattern. Kill by the process id you captured when you started the\nprocess.</p>\n\n</section>\n",
      "date_published": "2026-08-27T00:00:00+00:00"
    },
    {
      "id": "https://alchemy86.github.io/devlog/posts/every-failure-was-the-same-starter.html",
      "url": "https://alchemy86.github.io/devlog/posts/every-failure-was-the-same-starter.html",
      "title": "Every failure was the same starter",
      "summary": "A 26-agent swarm scored 88.5% and looked healthy. Watching the film instead of reading the table showed all three failures were Squirtle runs — one chance in 2,600. What the number could not show, and the reporting rule that came out of it.",
      "content_html": "<section class=\"prose\">\n\n  <h2>The number was fine. That was the problem.</h2>\n\n  <p>Twenty-three of twenty-six agents completed every milestone from a cold boot: out of the\nbedroom, up Route 1, into the Mart, back down again, and the Pokédex in hand. The\nconfidence interval was reported, the failures were located to a tile, and the three\nthat stopped were noted as stopping in Oak's Lab and on Route 1.</p>\n\n  <p>Everything about that report was true. Nothing about it said that one entire third of\nthe population failed <strong>every single time it was drawn</strong>.</p>\n\n  <p>The reason it was caught at all is that the captain watched the film rather than reading\nthe table. Twenty-six agents on screen at once, each in its own cell, each playing its\nown run — and the eye does something a summary statistic does not. It groups. Three\nagents stuck in the same room, and all three had the same Pokémon.</p>\n\n</section>\n\n<figure class=\"scrollfig\" aria-labelledby=\"fig-swarm-cap\">\n  <svg viewBox=\"0 0 720 296\" role=\"img\" xmlns=\"http://www.w3.org/2000/svg\" font-family=\"'JetBrains Mono', monospace\">\n    <style>\n      .c  { fill: var(--code-bg); stroke: var(--hairline); stroke-width: 1.5; }\n      .c.f{ fill: none; stroke: var(--accent); stroke-width: 2; stroke-dasharray: 4 3; }\n      .sp { fill: var(--ink); font-size: 15px; font-weight: 700; }\n      .sp.f{ fill: var(--accent); }\n      .mk { fill: var(--ink-soft); font-size: 12px; }\n      .mk.f{ fill: var(--accent); font-weight: 700; }\n      .hd { fill: var(--ink); font-size: 11.5px; font-weight: 700; letter-spacing: .1em; }\n      .hs { fill: var(--ink-soft); font-size: 10.5px; }\n    </style>\n    <text x=\"0\" y=\"16\" class=\"hd\">BEFORE — 23 / 26 = 88.5%</text>\n    <text x=\"696\" y=\"16\" text-anchor=\"end\" class=\"hs\">BULBASAUR 21/21 · CHARMANDER 2/2 · SQUIRTLE 0/3</text>\n    <rect x=\"0\" y=\"28\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"24.0\" y=\"50\" text-anchor=\"middle\" class=\"sp\">B</text>\n    <text x=\"24.0\" y=\"66\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"54\" y=\"28\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"78.0\" y=\"50\" text-anchor=\"middle\" class=\"sp\">B</text>\n    <text x=\"78.0\" y=\"66\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"108\" y=\"28\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"132.0\" y=\"50\" text-anchor=\"middle\" class=\"sp\">B</text>\n    <text x=\"132.0\" y=\"66\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"162\" y=\"28\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"186.0\" y=\"50\" text-anchor=\"middle\" class=\"sp\">B</text>\n    <text x=\"186.0\" y=\"66\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"216\" y=\"28\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"240.0\" y=\"50\" text-anchor=\"middle\" class=\"sp\">B</text>\n    <text x=\"240.0\" y=\"66\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"270\" y=\"28\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"294.0\" y=\"50\" text-anchor=\"middle\" class=\"sp\">B</text>\n    <text x=\"294.0\" y=\"66\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"324\" y=\"28\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"348.0\" y=\"50\" text-anchor=\"middle\" class=\"sp\">B</text>\n    <text x=\"348.0\" y=\"66\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"378\" y=\"28\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"402.0\" y=\"50\" text-anchor=\"middle\" class=\"sp\">B</text>\n    <text x=\"402.0\" y=\"66\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"432\" y=\"28\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"456.0\" y=\"50\" text-anchor=\"middle\" class=\"sp\">B</text>\n    <text x=\"456.0\" y=\"66\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"486\" y=\"28\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"510.0\" y=\"50\" text-anchor=\"middle\" class=\"sp\">B</text>\n    <text x=\"510.0\" y=\"66\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"540\" y=\"28\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"564.0\" y=\"50\" text-anchor=\"middle\" class=\"sp\">B</text>\n    <text x=\"564.0\" y=\"66\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"594\" y=\"28\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"618.0\" y=\"50\" text-anchor=\"middle\" class=\"sp\">B</text>\n    <text x=\"618.0\" y=\"66\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"648\" y=\"28\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"672.0\" y=\"50\" text-anchor=\"middle\" class=\"sp\">B</text>\n    <text x=\"672.0\" y=\"66\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"0\" y=\"82\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"24.0\" y=\"104\" text-anchor=\"middle\" class=\"sp\">B</text>\n    <text x=\"24.0\" y=\"120\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"54\" y=\"82\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"78.0\" y=\"104\" text-anchor=\"middle\" class=\"sp\">B</text>\n    <text x=\"78.0\" y=\"120\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"108\" y=\"82\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"132.0\" y=\"104\" text-anchor=\"middle\" class=\"sp\">B</text>\n    <text x=\"132.0\" y=\"120\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"162\" y=\"82\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"186.0\" y=\"104\" text-anchor=\"middle\" class=\"sp\">B</text>\n    <text x=\"186.0\" y=\"120\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"216\" y=\"82\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"240.0\" y=\"104\" text-anchor=\"middle\" class=\"sp\">B</text>\n    <text x=\"240.0\" y=\"120\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"270\" y=\"82\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"294.0\" y=\"104\" text-anchor=\"middle\" class=\"sp\">B</text>\n    <text x=\"294.0\" y=\"120\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"324\" y=\"82\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"348.0\" y=\"104\" text-anchor=\"middle\" class=\"sp\">B</text>\n    <text x=\"348.0\" y=\"120\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"378\" y=\"82\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"402.0\" y=\"104\" text-anchor=\"middle\" class=\"sp\">B</text>\n    <text x=\"402.0\" y=\"120\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"432\" y=\"82\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"456.0\" y=\"104\" text-anchor=\"middle\" class=\"sp\">C</text>\n    <text x=\"456.0\" y=\"120\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"486\" y=\"82\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"510.0\" y=\"104\" text-anchor=\"middle\" class=\"sp\">C</text>\n    <text x=\"510.0\" y=\"120\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"540\" y=\"82\" width=\"48\" height=\"48\" rx=\"6\" class=\"c f\" />\n    <text x=\"564.0\" y=\"104\" text-anchor=\"middle\" class=\"sp f\">S</text>\n    <text x=\"564.0\" y=\"120\" text-anchor=\"middle\" class=\"mk f\">✗</text>\n    <rect x=\"594\" y=\"82\" width=\"48\" height=\"48\" rx=\"6\" class=\"c f\" />\n    <text x=\"618.0\" y=\"104\" text-anchor=\"middle\" class=\"sp f\">S</text>\n    <text x=\"618.0\" y=\"120\" text-anchor=\"middle\" class=\"mk f\">✗</text>\n    <rect x=\"648\" y=\"82\" width=\"48\" height=\"48\" rx=\"6\" class=\"c f\" />\n    <text x=\"672.0\" y=\"104\" text-anchor=\"middle\" class=\"sp f\">S</text>\n    <text x=\"672.0\" y=\"120\" text-anchor=\"middle\" class=\"mk f\">✗</text>\n    <text x=\"0\" y=\"174\" class=\"hd\">AFTER THREE FIXES — 26 / 26 = 100.0%</text>\n    <text x=\"696\" y=\"174\" text-anchor=\"end\" class=\"hs\">BULBASAUR 21/21 · CHARMANDER 2/2 · SQUIRTLE 3/3</text>\n    <rect x=\"0\" y=\"186\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"24.0\" y=\"208\" text-anchor=\"middle\" class=\"sp\">B</text>\n    <text x=\"24.0\" y=\"224\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"54\" y=\"186\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"78.0\" y=\"208\" text-anchor=\"middle\" class=\"sp\">B</text>\n    <text x=\"78.0\" y=\"224\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"108\" y=\"186\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"132.0\" y=\"208\" text-anchor=\"middle\" class=\"sp\">B</text>\n    <text x=\"132.0\" y=\"224\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"162\" y=\"186\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"186.0\" y=\"208\" text-anchor=\"middle\" class=\"sp\">B</text>\n    <text x=\"186.0\" y=\"224\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"216\" y=\"186\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"240.0\" y=\"208\" text-anchor=\"middle\" class=\"sp\">B</text>\n    <text x=\"240.0\" y=\"224\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"270\" y=\"186\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"294.0\" y=\"208\" text-anchor=\"middle\" class=\"sp\">B</text>\n    <text x=\"294.0\" y=\"224\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"324\" y=\"186\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"348.0\" y=\"208\" text-anchor=\"middle\" class=\"sp\">B</text>\n    <text x=\"348.0\" y=\"224\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"378\" y=\"186\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"402.0\" y=\"208\" text-anchor=\"middle\" class=\"sp\">B</text>\n    <text x=\"402.0\" y=\"224\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"432\" y=\"186\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"456.0\" y=\"208\" text-anchor=\"middle\" class=\"sp\">B</text>\n    <text x=\"456.0\" y=\"224\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"486\" y=\"186\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"510.0\" y=\"208\" text-anchor=\"middle\" class=\"sp\">B</text>\n    <text x=\"510.0\" y=\"224\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"540\" y=\"186\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"564.0\" y=\"208\" text-anchor=\"middle\" class=\"sp\">B</text>\n    <text x=\"564.0\" y=\"224\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"594\" y=\"186\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"618.0\" y=\"208\" text-anchor=\"middle\" class=\"sp\">B</text>\n    <text x=\"618.0\" y=\"224\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"648\" y=\"186\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"672.0\" y=\"208\" text-anchor=\"middle\" class=\"sp\">B</text>\n    <text x=\"672.0\" y=\"224\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"0\" y=\"240\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"24.0\" y=\"262\" text-anchor=\"middle\" class=\"sp\">B</text>\n    <text x=\"24.0\" y=\"278\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"54\" y=\"240\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"78.0\" y=\"262\" text-anchor=\"middle\" class=\"sp\">B</text>\n    <text x=\"78.0\" y=\"278\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"108\" y=\"240\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"132.0\" y=\"262\" text-anchor=\"middle\" class=\"sp\">B</text>\n    <text x=\"132.0\" y=\"278\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"162\" y=\"240\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"186.0\" y=\"262\" text-anchor=\"middle\" class=\"sp\">B</text>\n    <text x=\"186.0\" y=\"278\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"216\" y=\"240\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"240.0\" y=\"262\" text-anchor=\"middle\" class=\"sp\">B</text>\n    <text x=\"240.0\" y=\"278\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"270\" y=\"240\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"294.0\" y=\"262\" text-anchor=\"middle\" class=\"sp\">B</text>\n    <text x=\"294.0\" y=\"278\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"324\" y=\"240\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"348.0\" y=\"262\" text-anchor=\"middle\" class=\"sp\">B</text>\n    <text x=\"348.0\" y=\"278\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"378\" y=\"240\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"402.0\" y=\"262\" text-anchor=\"middle\" class=\"sp\">B</text>\n    <text x=\"402.0\" y=\"278\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"432\" y=\"240\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"456.0\" y=\"262\" text-anchor=\"middle\" class=\"sp\">C</text>\n    <text x=\"456.0\" y=\"278\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"486\" y=\"240\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"510.0\" y=\"262\" text-anchor=\"middle\" class=\"sp\">C</text>\n    <text x=\"510.0\" y=\"278\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"540\" y=\"240\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"564.0\" y=\"262\" text-anchor=\"middle\" class=\"sp\">S</text>\n    <text x=\"564.0\" y=\"278\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"594\" y=\"240\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"618.0\" y=\"262\" text-anchor=\"middle\" class=\"sp\">S</text>\n    <text x=\"618.0\" y=\"278\" text-anchor=\"middle\" class=\"mk\">✓</text>\n    <rect x=\"648\" y=\"240\" width=\"48\" height=\"48\" rx=\"6\" class=\"c\" />\n    <text x=\"672.0\" y=\"262\" text-anchor=\"middle\" class=\"sp\">S</text>\n    <text x=\"672.0\" y=\"278\" text-anchor=\"middle\" class=\"mk\">✓</text>\n  </svg>        <figcaption id=\"fig-swarm-cap\">\n    <strong>The same twenty-six runs, before and after.</strong> B, C and S are the\n    starter each agent chose for itself — the harness reads it back off the cartridge,\n    and the network never sees it. Every dashed cell is a run that did not finish. The\n    aggregate moved from 88.5% to 100.0%, but the aggregate is not the finding. The\n    <em>shape</em> is.\n  </figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <h2>One in two thousand six hundred</h2>\n\n  <p>\"All three failures were the same thing\" is exactly the sort of pattern a human finds in\nnoise, so: with 21 Bulbasaur, 2 Charmander and 3 Squirtle runs and no species effect at\nall, the probability that the three failures land on the three Squirtle runs is about\n<strong>1 in 2,600</strong>. p ≈ 0.00038.</p>\n\n  <p>That is not a coincidence you shrug at. And it was the <em>second</em> time this exact shape of\nbug had appeared in this project, which is what turned it from an incident into a rule.</p>\n\n  <div class=\"callout\">\n  <p class=\"eyebrow\">The standing order that came out of it</p>\n  <p>\n    <strong>Report per starter on every certification and every swarm.</strong> Not\n    when it looks relevant. Every time. An aggregate over a population with a\n    structural split in it is a number that is simultaneously correct and useless.\n  </p>\n</div>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>Why the film sees what the table cannot</h2>\n\n  <p>Not because a film is nicer to look at. Because of what each representation can carry.</p>\n\n  <p>A completion table has one row per milestone and one rate per row. It is a <em>marginal</em> —\nit has already summed over the population, and a correlation between a run's hidden\nattribute and its outcome is exactly the information summing destroys. You cannot\nrecover it from the table no matter how carefully you read, because it is not in the\ntable.</p>\n\n  <p>The film has not summed over anything yet. Every agent is still a separate object on\nscreen, carrying everything about itself, and the failures are visible <em>as a group</em> —\nthree cells stuck in the same room at the same time is a thing you see rather than\ncompute.</p>\n\n  <div class=\"pullquote\">\n  <p>\n    The swarm film is not a nicer way of showing the number. It is the only artefact\n    in the pipeline where the population has not been collapsed yet.\n  </p>\n  <cite>What this cost, and what it bought</cite>\n</div>\n\n  <p>It is not free. The film that showed this takes roughly twenty-four screenshots per\ndecision per agent — gigabytes — where the table costs nothing but the emulation. It is\nthe expensive artefact, and this is what it is for.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>Three separate causes, none of them the one first suspected</h2>\n\n  <p>The obvious hypothesis was that the training corpus was biased toward one starter, so\nthe student was simply worse with the others. That was checked, and it is not what was\nhappening.</p>\n\n  <p>The starter <em>choice</em> is genuinely balanced. At the chain's own entry state the first\ndecision carries 0.992 bits of entropy, and over 500 sampled attempts the committed\nstudent takes Bulbasaur 254 times, Squirtle 127 and Charmander 118, reaching the goal in\n499 of 500. That is a real three-way split, not a collapse.</p>\n\n  <p>What <em>was</em> true, and actionable, is narrower and less obvious: two of the links on the\nreturn leg have exactly <strong>one</strong> recorded start state each, so their corpora contained\n<strong>zero species variation</strong> — regardless of how balanced the entry choice was. The\nstudent had simply never been shown those rooms with a Squirtle in the party.</p>\n\n  <p>Pulling the three failures apart gave three unrelated causes:</p>\n\n</section>\n\n<div class=\"cards\">\n  <div class=\"card\">\n    <div class=\"card-hd\">\n      <p class=\"kicker\">Two agents</p>\n      <h3>Reached Oak and never spoke to him</h3>\n    </div>\n    <div class=\"card-bd\">\n      <p>\n        They walked into him, forever. At the four interaction tiles, facing correctly,\n        the base policy's own prediction is the right button only <strong>4.55%</strong>\n        of the time — the corpus mostly demonstrates the <em>dialogue</em> that follows\n        the first press, not the press that starts it.\n      </p>\n      <p>\n        Fixed with a dedicated goal whose positives were harvested structurally from the\n        link's own existing corpora at the four declared tile-and-facing spots.\n      </p>\n    </div>\n  </div>\n  <div class=\"card\">\n    <div class=\"card-hd\">\n      <p class=\"kicker\">One agent</p>\n      <h3>Deadlocked in a battle menu for 3,600 decisions</h3>\n    </div>\n    <div class=\"card-bd\">\n      <p>\n        Traced directly on a real seed: a wild Rattata at 8/23 HP, and the agent pressed\n        <code>right</code> forever with the HP never once changing. The return crossing\n        of Route 1 was still set to flee-only — the exact state the <em>outbound</em>\n        crossing had been in before its own upgrade.\n      </p>\n      <p>\n        It was also explicitly ruled out that the trainer-battle goal was false-firing\n        here: its own history had stopped growing well before the deadlock began.\n      </p>\n    </div>\n  </div>\n  <div class=\"card\">\n    <div class=\"card-hd\">\n      <p class=\"kicker\">One agent</p>\n      <h3>Whited out and never recovered</h3>\n    </div>\n    <div class=\"card-bd\">\n      <p>\n        The rule that a whiteout must not end a run was already active. The real gap was\n        that nothing had ever taught the student what to do once it wakes up at home.\n      </p>\n      <p>\n        Fixed for free: a whiteout this early teleports the party to the player's own\n        house, and the link's goal is simply \"be outdoors in Pallet Town\" — so walking\n        out of the house satisfies it, and two existing links already do exactly that at\n        100%. No new data was collected at all.\n      </p>\n    </div>\n  </div>\n</div>\n\n<section class=\"prose\">\n\n  <h2>The fix that broke everything, and what it taught</h2>\n\n  <p>The first wiring of the Oak-interaction goal took the whole chain from 88.5% to <strong>0 of\n150</strong>.</p>\n\n  <p>The trigger tile it had been trained on — one specific tile, facing one specific\ndirection — is, independently, the chain's own <em>entry</em> tile for taking a starter six\nlinks earlier. Same physical room, visited three times by this chain for three different\nreasons. An ungated goal that fires whenever it recognises its screen fired on the very\nfirst approach to the Poké Balls and broke every single run.</p>\n\n  <p>The fix was structural rather than a heuristic: the late-chain goals are now only ever\nconsulted once a return-leg stage has <em>already</em> latched. Not by convention — by\nconstruction. A screen that a return-leg goal happens to recognise can no longer hijack\nthe outward leg, however visually identical it is to something further down the chain.</p>\n\n  <p>There is a general shape here worth naming. In a route that revisits the same rooms, <strong>a\nrecogniser's precision is not a property of the recogniser</strong>. It is a property of the\nrecogniser <em>and</em> the window of the episode it is allowed to look in. Ours was excellent\nat its job and catastrophic without a gate.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>Where it landed</h2>\n\n  <p>After the three fixes, an eight-agent smoke test first — 8/8 — before committing to the\nlong run. Then a cold-boot certification at N=150:</p>\n\n  <div class=\"table-wrap\">\n  <table>\n    <thead>\n      <tr>\n        <th>Starter</th>\n        <th class=\"num\">Completed the whole chain</th>\n        <th class=\"num\">Rate</th>\n        <th class=\"num\">95% interval</th>\n      </tr>\n    </thead>\n    <tbody>\n      <tr><td>BULBASAUR</td><td class=\"num\">87 / 90</td><td class=\"num\">96.7%</td><td class=\"num\">90.7–98.9%</td></tr>\n      <tr><td>CHARMANDER</td><td class=\"num\">13 / 13</td><td class=\"num\">100.0%</td><td class=\"num\">77.2–100.0%</td></tr>\n      <tr><td>SQUIRTLE</td><td class=\"num\">45 / 47</td><td class=\"num\">95.7%</td><td class=\"num\">85.8–98.8%</td></tr>\n      <tr><td><strong>All sixteen links</strong></td><td class=\"num\"><strong>145 / 150</strong></td><td class=\"num\"><strong>96.67%</strong></td><td class=\"num\"><strong>92.4–98.6%</strong></td></tr>\n    </tbody>\n  </table>\n</div>\n\n  <p>No starter anywhere near zero, all three intervals overlapping heavily. The filmed swarm\nat N=26 came back 26/26 — the first time this chain's film has shown every starter\ncompleting at 100%, where the previous one showed a third of them at zero.</p>\n\n  <p>N=150 is not the project's 3,000-attempt convention, and bounds failure near 2%, not\n0.1%. And Charmander's 13/13 has a lower interval bound of 77.2%: thirteen runs is\nevidence of not-obviously-broken, not of perfection.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>What this actually generalises to</h2>\n\n  <p>Very little of the above is about Pokémon.</p>\n\n  <p>An agent population with a self-selected hidden attribute — which tool it picked, which\nbranch it took, which variant it was served — will produce an aggregate success rate\nthat is arithmetically correct and behaviourally meaningless the moment that attribute\ncorrelates with outcome. The failure mode is not a wrong number. It is a right number\nanswering a question nobody asked.</p>\n\n  <p>Two cheap defences came out of this. Break every rate down by the attribute, whether or\nnot you expect it to matter. And keep one artefact in the pipeline where the population\nhas not been collapsed yet — expensive, rarely looked at, and the only place a\nstructural split is visible before it becomes a mystery.</p>\n\n</section>\n",
      "date_published": "2026-08-27T00:00:00+00:00"
    },
    {
      "id": "https://alchemy86.github.io/devlog/posts/a-hundred-checks-in-one-session.html",
      "url": "https://alchemy86.github.io/devlog/posts/a-hundred-checks-in-one-session.html",
      "title": "A hundred checks in one session",
      "summary": "A new check found a real bug in TerminalGB on the day it was written — one that thousands of rows across five public suites could not see, because of the shape they have.",
      "content_html": "<section class=\"prose\">\n\n  <h2>The fault</h2>\n\n  <p>A flag the picture processor keeps about a running object transfer was cleared on one of\nthe two paths that can notice the transfer has ended, and not the other. The idle arm's\nown comment claimed the default machine never reached it.</p>\n\n  <p>It does reach it. The transfer's last machine cycle leaves the position counter at its\nlimit inside the bus tick without the flag moving, so the instruction's remainder is\nwhere the transfer gets noticed to be over.</p>\n\n  <p>Once the flag latched, the object scan <strong>never read object memory again for the rest of\nthe session</strong> — 192 of 550 frames of a real cartridge.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>Why a suite of short ROMs cannot see it</h2>\n\n  <p>Each one boots, measures one thing and stops. A latch that needs a transfer to end on an\ninstruction boundary and a scan to follow it never gets the chance.</p>\n\n  <p>That is not a criticism of those suites. It is a property of their shape.</p>\n\n  <div class=\"pullquote\">\n  <p>\n    A cartridge that runs a hundred checks back to back in one session is a shape no\n    test ROM has.\n  </p>\n</div>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>The check itself, which is a nice piece of indirection</h2>\n\n  <p>A cartridge cannot see which objects the scan found. What it <em>can</em> see is how long mode\n3 took, and ten objects on a line cost the fetcher at least sixty dots.</p>\n\n  <p>So: leave object memory entirely empty, put the visible objects in the transfer's\nsource, and start the transfer so it covers the measured line's scan. A machine whose\nscan reads object memory straight through the transfer finds the ten objects the\ntransfer has already written and is still drawing them. Hardware finds none and is\nalready in horizontal blank.</p>\n\n  <p>Two details are load-bearing rather than decorative. Object memory is left empty on\npurpose, so whatever slot the scan last managed to read, it read a zero — the frozen Y\nputs the phantom object above the screen, and the check does not depend on where the\nfreeze landed. And the transfer is sourced from video memory rather than work memory,\nbecause on a monochrome console work memory sits on the cartridge's own bus and a\ntransfer out of it would feed the processor its own bytes instead of instructions. That\nis why every real game's transfer routine lives in high RAM.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>The rule it left behind</h2>\n\n  <p>When a check is written, run the whole cartridge and read the total, not just that\ncheck's line. A new check that passes in isolation and moves an unrelated area's verdict\nhas found something.</p>\n\n</section>\n",
      "date_published": "2026-08-27T00:00:00+00:00"
    },
    {
      "id": "https://alchemy86.github.io/devlog/posts/271-colours-in-a-four-shade-picture.html",
      "url": "https://alchemy86.github.io/devlog/posts/271-colours-in-a-four-shade-picture.html",
      "title": "271 colours in a four-shade picture",
      "summary": "A terminal half-block renderer looked blurry on GNOME terminals and crisp on WezTerm. The cause was a hard-coded smoothing filter four lines down in a dependency.",
      "content_html": "<section class=\"prose\">\n\n  <p>A terminal that speaks no image protocol gets the picture drawn out of the\nupper-half-block glyph <code class=\"language-plaintext highlighter-rouge\">▀</code>. The foreground colour paints the top half of a character\ncell, the background paints the bottom, two vertical pixels per cell. That is crisp by\nconstruction — a cell is two flat colours and there is nothing inside it that can be\nsoft.</p>\n\n  <p>And yet on Ptyxis it was visibly blurry, and on WezTerm it was not. Same binary, same\nROM, same scale.</p>\n\n</section>\n\n<div class=\"fig-pair\">\n  <figure class=\"pixel\">\n    <p class=\"cap\">Before · <code>render_path = legacy</code></p>\n    <img src=\"../assets/img/terminalgb/halfblocks-blurry.png\" width=\"1000\" height=\"572\" alt=\"The dmg-acid2 demon face drawn with half-block characters, visibly soft and smeared, with grey fringes around every edge.\" />\n    <figcaption>\n      Every cell is a weighted average of the Game Boy pixels underneath it.\n    </figcaption>\n  </figure>\n  <figure class=\"pixel\">\n    <p class=\"cap\"><span class=\"accent\">After</span> · default path</p>\n    <img src=\"../assets/img/terminalgb/halfblocks-crisp.png\" width=\"1000\" height=\"572\" alt=\"The same dmg-acid2 demon face drawn with half-block characters, now with hard edges and flat blocks of tone.\" />\n    <figcaption>\n      Sampled nearest-neighbour at pixel centres, straight out of the framebuffer.\n    </figcaption>\n  </figure>\n</div>\n\n<p class=\"note\" style=\"max-width:var(--measure);margin-top:14px;\">\n  Both captures in Ptyxis 50.1 at 80×24 cells, 2.8× scale, one binary, two render\n  paths.\n</p>\n\n<section class=\"prose\">\n\n  <h2>The softness was never in the glyph</h2>\n\n  <p>It was in the sampling, four lines down in a dependency:</p>\n\n  <figure class=\"code\">\n  <pre><code>let img = img.resize_exact(rect.width as u32, (rect.height * 2) as u32,\n                          FilterType::Triangle);</code></pre>\n  <figcaption>\n    <code>ratatui-image-4.2.0/src/protocol/halfblocks.rs</code>. The same crate's\n    Sixel encoder does no such thing, and <code>Resize::Scale</code>'s own default\n    filter is <code>FilterType::Nearest</code>. Half-blocks was the one path with a\n    filter baked in — which is why WezTerm, on the Sixel path, looked right.\n  </figcaption>\n</figure>\n\n  <p>Measured on dmg-acid2 at 80×24 cells: 271 distinct colours, 268 of which no Game Boy\nshade maps to.</p>\n\n  <p>The fix samples the cells directly, nearest-neighbour at pixel centres, the same rule\nthe video scaler already used. It also writes a uniform cell as a space rather than <code class=\"language-plaintext highlighter-rouge\">▀</code>,\nso a font with a poor block glyph cannot soften the large flat areas a Game Boy picture\nis mostly made of.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>Doing the work ourselves is cheaper</h2>\n\n  <p>This is the part that surprised me. The new path pays a full sampling cost on every\nframe and still wins: over roughly 1,070 frames at 146×54 cells, same ROM and window\nboth sides, whole-frame time went from 0.460 ms to 0.349 ms.</p>\n\n  <p>It replaces two <code class=\"language-plaintext highlighter-rouge\">image</code>-crate resizes — a nearest upscale to the display's pixel size,\nthen a Triangle downscale back to the cell grid. One pass of arithmetic beats two passes\nof somebody else's.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>The guard is a property, not a pixel</h2>\n\n  <p>Blur has now been reported twice here, so the regression test asserts the thing that\nmatters: <strong>every colour on screen must be a colour that was in the framebuffer.</strong> No\ninterpolating resampler can satisfy that.</p>\n\n  <p>One unit test runs a one-pixel checkerboard — the worst case for a smoothing filter — at\nfive window sizes. One end-to-end test drives the real render on dmg-acid2 at four.</p>\n\n  <div class=\"callout\">\n  <p class=\"eyebrow\">The same trap, one repository over</p>\n  <p>\n    <a href=\"../projects/pixelgb.html\">PixelGB</a> extracts map art from a running\n    cartridge and guards its output on the same rule — no colour may appear that was\n    not in the source — and cites this incident as the reason.\n  </p>\n</div>\n\n</section>\n",
      "date_published": "2026-08-27T00:00:00+00:00"
    },
    {
      "id": "https://alchemy86.github.io/devlog/posts/terminalgb-double-speed-accuracy.html",
      "url": "https://alchemy86.github.io/devlog/posts/terminalgb-double-speed-accuracy.html",
      "title": "The double-speed bug that cost 2,304 pixels",
      "summary": "A one-dot register-commit stagger, calibrated on single-speed test ROMs, silently vanished in double speed — drawing a wrong stripe across the screen. Fixing it took an AGE reference ROM from 2,304 wrong pixels to a clean pass, and explains why TerminalGB ships two picture engines.",
      "content_html": "<section class=\"prose\">\n\n  <h2>The symptom</h2>\n\n  <p>A Game Boy Color game that flips <code class=\"language-plaintext highlighter-rouge\">LCDC</code> bits partway through a scanline — the register\nthat controls which tile sources the picture processor is reading from — came out with a\nvisibly wrong stripe pattern, but <em>only</em> when the console was running in double-speed\nmode. The same game in normal speed was pixel-exact.</p>\n\n  <p>That \"only in double speed\" is the whole tell. When one variant of a scene is perfect\nand its faster-clocked twin is wrong, the bug is not in the drawing logic — the drawing\nlogic is provably correct at single speed. The bug is in how time is being counted.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>Two clocks, one of which doubles</h2>\n\n  <p>The Game Boy Color can switch its CPU into a double-speed mode. The important,\neasily-forgotten detail is that this does <em>not</em> speed up the screen. The picture\nprocessor's dot clock is fixed; only the CPU's own clock doubles. So the unit that a lot\nof internal timing is measured in — the CPU machine cycle, or \"M-cycle\" — changes width\ndepending on the mode:</p>\n\n</section>\n\n<figure aria-labelledby=\"fig1-cap\">\n  <svg viewBox=\"0 0 720 300\" role=\"img\" xmlns=\"http://www.w3.org/2000/svg\" font-family=\"'JetBrains Mono', monospace\">\n    <style>\n      .cell   { fill: var(--code-bg); stroke: var(--hairline); stroke-width: 1.5; }\n      .stag   { fill: var(--accent);  opacity: .18; }\n      .stag-b { fill: none; stroke: var(--accent); stroke-width: 1.5; }\n      .lbl    { fill: var(--ink-soft); font-size: 12px; letter-spacing: .04em; }\n      .ttl    { fill: var(--ink); font-size: 12px; font-weight: 700; letter-spacing: .06em; }\n      .ok     { fill: var(--ink); font-size: 12px; }\n      .bad    { fill: var(--accent); font-size: 12px; font-weight: 700; }\n      .dot    { fill: var(--ink-soft); font-size: 11px; }\n    </style>\n\n    <!-- SINGLE SPEED -->\n    <text x=\"0\" y=\"30\" class=\"ttl\">SINGLE SPEED — 4 DOTS PER M-CYCLE</text>\n    <!-- 4 cells, 120px each -->\n    <rect x=\"0\" y=\"46\" width=\"120\" height=\"56\" class=\"cell\" />\n    <rect x=\"120\" y=\"46\" width=\"120\" height=\"56\" class=\"cell\" />\n    <rect x=\"240\" y=\"46\" width=\"120\" height=\"56\" class=\"cell\" />\n    <rect x=\"360\" y=\"46\" width=\"120\" height=\"56\" class=\"cell\" />\n    <text x=\"60\" y=\"80\" text-anchor=\"middle\" class=\"dot\">dot 1</text>\n    <text x=\"180\" y=\"80\" text-anchor=\"middle\" class=\"dot\">dot 2</text>\n    <text x=\"300\" y=\"80\" text-anchor=\"middle\" class=\"dot\">dot 3</text>\n    <text x=\"420\" y=\"80\" text-anchor=\"middle\" class=\"dot\">dot 4</text>\n    <!-- 1-dot stagger occupies dot 1 -->\n    <rect x=\"0\" y=\"46\" width=\"120\" height=\"56\" class=\"stag\" />\n    <rect x=\"0\" y=\"46\" width=\"120\" height=\"56\" class=\"stag-b\" />\n    <text x=\"60\" y=\"122\" text-anchor=\"middle\" class=\"lbl\">stagger</text>\n    <text x=\"300\" y=\"122\" text-anchor=\"middle\" class=\"ok\">value applied ✓ (3 dots spare)</text>\n\n    <!-- DOUBLE SPEED -->\n    <text x=\"0\" y=\"196\" class=\"ttl\">DOUBLE SPEED — 2 DOTS PER M-CYCLE</text>\n    <rect x=\"0\" y=\"212\" width=\"120\" height=\"56\" class=\"cell\" />\n    <rect x=\"120\" y=\"212\" width=\"120\" height=\"56\" class=\"cell\" />\n    <text x=\"60\" y=\"246\" text-anchor=\"middle\" class=\"dot\">dot 1</text>\n    <text x=\"180\" y=\"246\" text-anchor=\"middle\" class=\"dot\">dot 2</text>\n    <!-- 1-dot stagger consumes the whole window (both dots) -->\n    <rect x=\"0\" y=\"212\" width=\"240\" height=\"56\" class=\"stag\" />\n    <rect x=\"0\" y=\"212\" width=\"240\" height=\"56\" class=\"stag-b\" />\n    <text x=\"120\" y=\"288\" text-anchor=\"middle\" class=\"lbl\">stagger consumes the entire M-cycle</text>\n    <!-- commit falls off the edge -->\n    <text x=\"360\" y=\"246\" class=\"bad\">✗ value never applied</text>\n    <line x1=\"240\" y1=\"240\" x2=\"345\" y2=\"240\" stroke=\"var(--accent)\" stroke-width=\"1.5\" stroke-dasharray=\"4 4\" />\n  </svg>\n  <figcaption id=\"fig1-cap\">\n    A one-dot register-commit stagger fits comfortably inside a four-dot M-cycle.\n    Halve the M-cycle and the same one dot consumes the whole thing — leaving no\n    room for the deferred value to land.\n  </figcaption>\n</figure>\n\n<section class=\"prose\">\n\n  <h2>The one-dot stagger</h2>\n\n  <p>Real Color hardware doesn't make an <code class=\"language-plaintext highlighter-rouge\">LCDC</code> write visible at the exact instant the CPU\nperforms it — a couple of the bits become visible to the picture processor one dot later\nthan the rest. TerminalGB modelled that faithfully with a one-dot \"early\" stagger on the\nmemory unit's <code class=\"language-plaintext highlighter-rouge\">LCDC</code> write-commit: hold the change back by a dot, then apply it.</p>\n\n  <p>The trouble is where that one dot came from. The stagger was calibrated exclusively\nagainst a suite of single-speed reference ROMs, where an M-cycle is four dots wide. A\none-dot delay inside a four-dot budget is comfortable. But in double speed the M-cycle\nis only two dots wide, and the deferred value's slot fell off the end of the cycle. The\ncommit was <em>silently never applied</em> — no error, no assertion, just a value that quietly\nevaporated and a stripe drawn from the wrong tile source for one dot too long.</p>\n\n  <div class=\"callout\">\n  <p class=\"eyebrow\">The general trap</p>\n  <p>\n    A timing offset measured in absolute dots is only correct for the clock it was\n    measured on. The moment the surrounding cycle changes width, an offset that\n    \"fit comfortably\" can consume the entire window — and because nothing overflows,\n    nothing complains.\n  </p>\n</div>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>Finding it</h2>\n\n  <p>It surfaced as a hard reference failure, not a bug report. The accuracy harness runs the\nAGE test-ROM <code class=\"language-plaintext highlighter-rouge\">m3-bg-lcdc-ds@cgbBCE</code> — a Color, double-speed ROM built specifically to\nstress mid-scanline <code class=\"language-plaintext highlighter-rouge\">LCDC</code> writes — and compares the rendered frame against a\nhardware-captured reference image. It read <strong>2,304 of 23,040 pixels wrong</strong>. Its\nsingle-speed sibling, <code class=\"language-plaintext highlighter-rouge\">m3-bg-lcdc@cgbBCE</code>, was already pixel-exact. One passing, one\nfailing, identical but for the speed switch: that pair is what pointed straight at the\nclock, not the renderer.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>The fix</h2>\n\n  <p>The commit routine now knows what speed it is running at. Where it used to apply a fixed\none-dot stagger, it takes the running <code class=\"language-plaintext highlighter-rouge\">GbSpeed</code> and drops the stagger to zero when there\nis no room for it:</p>\n\n  <pre><code>// ppu_write_commit — CGB LCDC arm\nlet early = match speed {\n    GbSpeed::Single =&gt; 1,   // 4-dot M-cycle: a spare dot exists, model the hardware delay\n    GbSpeed::Double =&gt; 0,   // 2-dot M-cycle: no spare dot — apply immediately instead\n};</code></pre>\n\n  <p>Removing the stagger outright in double speed beats leaving it in to be silently\ntruncated. The single-speed path is untouched, so nothing that already passed regresses.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>What actually happened to the numbers</h2>\n\n  <p><code class=\"language-plaintext highlighter-rouge\">m3-bg-lcdc-ds@cgbBCE</code> went from a 2,304-pixel failure to a pixel-exact pass, moving the\nAGE suite from 10 to 11 of 59, and the Gambatte double-speed rows improved on the\naccurate engine. Five more rows fell sharply without reaching zero:</p>\n\n  <div class=\"table-wrap\">\n  <table>\n    <thead>\n      <tr>\n        <th>Reference row (double speed)</th>\n        <th class=\"num\">Before</th>\n        <th class=\"num\">After</th>\n      </tr>\n    </thead>\n    <tbody>\n      <tr><td class=\"mono\">m3-bg-lcdc-ds@cgbBCE</td><td class=\"num\">2,304</td><td class=\"num\">PASS</td></tr>\n      <tr><td class=\"mono\">bgtiledata_spx08_ds_3</td><td class=\"num\">1,032</td><td class=\"num\">8</td></tr>\n      <tr><td class=\"mono\">bgtiledata_spx08_ds_4</td><td class=\"num\">2,064</td><td class=\"num\">16</td></tr>\n      <tr><td class=\"mono\">bgtiledata_spx09_ds_1</td><td class=\"num\">1,144</td><td class=\"num\">8</td></tr>\n      <tr><td class=\"mono\">bgtiledata_spx09_ds_3</td><td class=\"num\">1,144</td><td class=\"num\">8</td></tr>\n      <tr><td class=\"mono\">bgtiledata_spx09_ds_4</td><td class=\"num\">2,048</td><td class=\"num\">16</td></tr>\n    </tbody>\n  </table>\n</div>\n\n  <p>Those remainders are a different, smaller timing discrepancy that the stagger bug was\nmasking. Eight wrong pixels are reported as eight, so the next person to open that\nscoreboard sees exactly how much is left to chase.</p>\n\n  <p>The regression is locked in with a test that has teeth: reverting the stagger to a fixed\n<code class=\"language-plaintext highlighter-rouge\">1</code> unconditionally reproduces the original 2,304-pixel failure, so the mistake cannot\nquietly come back.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>A note on counting pixels</h2>\n\n  <p>Not every \"wrong pixels\" number on the scoreboard is a raw count of differing pixels.\nThe Mealybug Tearoom comparisons use a shade-rank distance, which is deliberately\nunforgiving: a frame that introduces one extra distinct shade can report on the order of\n23,040 \"wrong\" no matter how much of the rest is perfect, and a four-pixel error can\nmove the total by tens of thousands. Four genuinely wrong pixels there scores 22,070.</p>\n\n  <p>So these figures are never converted to a percentage. The 2,304 and the residual counts\nabove <em>are</em> direct pixel counts from the AGE and Gambatte comparisons; a shade-rank\ndistance is treated as an ordering signal, not a pixel tally.</p>\n\n</section>\n\n<section class=\"prose\">\n\n  <h2>Why this needed the accurate engine at all</h2>\n\n  <p>A one-dot, mid-scanline error is invisible to a fast emulator by construction — which is\nexactly why TerminalGB carries two picture engines rather than one.</p>\n\n  <p>The <strong><code class=\"language-plaintext highlighter-rouge\">standard</code></strong> engine draws a whole scanline in a single step at the end of mode 3,\nfrom whatever the registers hold at that instant. It is fast and it is correct for the\noverwhelming majority of software, but it physically cannot represent \"the wrong tile\nsource for one dot in the middle of a line\" — it never looks at the registers mid-line.\nThe <strong><code class=\"language-plaintext highlighter-rouge\">identical</code></strong> engine walks the real hardware pixel pipeline dot by dot: the\nbackground fetcher, the eight-pixel FIFO, sprite fetches, the window restart, the <code class=\"language-plaintext highlighter-rouge\">SCX &amp;\n7</code> discard. A mid-scanline write lands exactly where a Game Boy puts it — which means a\none-dot timing bug lands exactly there too, and gets caught.</p>\n\n  <p>The two are not a quality or an appearance setting. On ordinary games they produce\nbyte-identical framebuffers — verified across 600 frames of dmg-acid2 plus Blargg's\n<code class=\"language-plaintext highlighter-rouge\">cpu_instrs</code>. The only axis between them is exactness against speed:</p>\n\n  <div class=\"table-wrap\">\n  <table>\n    <thead>\n      <tr>\n        <th>Test suite</th>\n        <th class=\"num\"><code>standard</code></th>\n        <th class=\"num\"><code>identical</code></th>\n      </tr>\n    </thead>\n    <tbody>\n      <tr><td>Mooneye GB acceptance</td><td class=\"num\">67 / 75</td><td class=\"num\">75 / 75</td></tr>\n      <tr><td>Mealybug Tearoom (pixel-exact rows)</td><td class=\"num\">3 / 79</td><td class=\"num\">29 / 79</td></tr>\n      <tr><td>Gambatte (5,225 scored rows)</td><td class=\"num\">3,176</td><td class=\"num\">3,622</td></tr>\n      <tr><td>GBMicrotest</td><td class=\"num\">252 / 513</td><td class=\"num\">339 / 513</td></tr>\n      <tr><td>GB Emulator Shootout (264 rows)</td><td class=\"num\">223</td><td class=\"num\">243</td></tr>\n      <tr><td>Frame cost, Pokémon Blue (one P-core)</td><td class=\"num\">0.094 ms</td><td class=\"num\">0.373 ms</td></tr>\n    </tbody>\n  </table>\n</div>\n\n  <p>The accurate engine costs roughly four times as much per frame — 0.373 ms against 0.094\nms, still only a couple of percent of a frame's budget on a desktop core. That is cheap\nenough to be the default, and it is: <code class=\"language-plaintext highlighter-rouge\">identical</code> has been the shipping default since it\nstopped losing accuracy rows the fast engine kept. But four times the cost is not free\neverywhere. On the PSP frontend, where the CPU budget is tight, the emulator\ndeliberately pins <code class=\"language-plaintext highlighter-rouge\">standard</code> — an unplayable-but-exact picture helps no one.</p>\n\n  <p>That is the whole reason the split exists. The fast engine is what makes the emulator\nusable on modest hardware; the accurate engine is what makes a bug like this one\n<em>findable</em>. Ship only the fast one and the double-speed stripe would still be on screen,\nunmeasured and unfixed, because nothing in the pipeline would ever have looked closely\nenough to see it.</p>\n\n</section>\n",
      "date_published": "2026-08-26T00:00:00+00:00"
    }
  ]
}
