{"collection":"posts","slug":"1775137360175-i-got-a-common-turtle","cid":"bafkreiap6wqfxuxt4ynrqtgfyf4zjatlbtkpkhcnd2f45romtfc2tdsuiu","title":"I Got a Common Turtle","excerpt":"I got a Common turtle from Claude Code's deterministic buddy system, so I brute-forced the generation algorithm.","body":"On April 1st, 2026, Anthropic shipped a tamagotchi-style terminal pet called **Buddy** as an easter egg inside Claude Code. Type `/buddy` and a little ASCII creature hatches next to your input line. It watches your conversations, drops comments in speech bubbles, and has its own name, personality, and stats. Delightful.\n\nYour buddy is **deterministic**, generated from a hash of your account UUID. You don't get to pick your species, rarity, or stats. You get what you get.\n\nI got a Common turtle.\n\nBaseline stats, no hat, no shimmer. A slow, unremarkable cretin assigned to me by the cold math of a hash function. People online are showing off Legendary Shiny Dragons with maxed-out chaos stats and tiny duck hats. Something had to be done.\n\nSo I brute-forced the generation algorithm and built a tool to hunt for better seeds.\n\n## The Generation Pipeline\n\n```mermaid\nflowchart LR\n    A[accountUuid] --\u003e B[\"+ salt 'friend-2026-401'\"]\n    B --\u003e C[Wyhash → u32]\n    C --\u003e D[Mulberry32 PRNG]\n    D --\u003e E[rarity]\n    D --\u003e F[species]\n    D --\u003e G[eyes]\n    D --\u003e H[hat]\n    D --\u003e I[shiny]\n    D --\u003e J[stats]\n```\n\nThe pipeline reads `oauthAccount.accountUuid` from `~/.claude.json`, concatenates it with the salt `\"friend-2026-401\"`, hashes it with **Wyhash** (`Bun.hash()`) truncated to u32, seeds a **Mulberry32** PRNG, and rolls traits sequentially.\n\nSame UUID in, same buddy out. Reinstalling changes nothing. Physical traits regenerate from the hash every launch. Only the name and personality persist locally.\n\nThe pipeline only cares about the UUID string. Swap it in the config for one that hashes to better traits and you get a different buddy. Auth tokens live separately, so login is unaffected.\n\n## Species\n\n18 species, uniformly distributed. Dragons, capybaras, axolotls, ghosts, geese, etc. Assignment is purely a function of the hash.\n\n## Rarity\n\nWeighted probabilities with a separate shiny roll:\n\n| Rarity    | Probability | Stat Floor | Features                          |\n|-----------|-------------|------------|-----------------------------------|\n| Common    | 60%         | 5          | Basic appearance, no hat          |\n| Uncommon  | 25%         | 15         | Unlocks hat accessories           |\n| Rare      | 10%         | 25         | More accessory options            |\n| Epic      | 4%          | 35         | Exclusive accessories, high stats |\n| Legendary | 1%          | 50         | Top-tier accessories, max stats   |\n\nEvery buddy has an independent **1% shiny chance**, adding iridescent shimmer and particle effects regardless of rarity.\n\nCombined probabilities:\n\n| Combination                          | Probability     |\n|--------------------------------------|-----------------|\n| Legendary                            | 1/100           |\n| Shiny                                | 1/100           |\n| Legendary + Shiny                    | 1/10,000        |\n| Specific Species + Legendary         | ~1/1,800        |\n| Specific Species + Legendary + Shiny | ~1/180,000      |\n\n## Appearance\n\n6 eye styles: `· ✦ × ◉ @ °`\n\n8 hats, gated by rarity. Common buddies get nothing. Uncommon unlocks crowns, top hats, and propellers. Rare adds halos and wizard hats. Epic gets beanies. Legendary gets the tiny duck.\n\n## Stats\n\n5 attributes shape the buddy's personality and interaction style, ranked here by coding utility:\n\n| Rank | Stat      | Why                                     |\n|------|-----------|-----------------------------------------|\n| 1    | Debugging | The whole point of a buddy              |\n| 2    | Wisdom    | Pattern recognition, architecture sense |\n| 3    | Patience  | Long sessions, complex problems         |\n| 4    | Chaos     | Creative solutions, lateral thinking    |\n| 5    | Snark     | Fun but least useful                    |\n\nA high-chaos goose with max snark will roast your bugs. A patient owl with high wisdom offers constructive advice. The species-attribute combination drives the entire interaction personality.\n\nEvery buddy has one **peak** attribute (highest) and one **dump** attribute (lowest). The rest distribute randomly. Total points scale with rarity. A Legendary buddy's dump stat is higher than a Common buddy's peak.\n\nThe formulas for a Legendary (stat floor 50):\n\n| Type   | Formula                          | Range  |\n|--------|----------------------------------|--------|\n| Peak   | min(100, floor(50 + 50 + rand × 30)) | 100    |\n| Normal | floor(50 + rand × 40)           | 50–89  |\n| Dump   | max(1, floor(50 − 10 + rand × 15))  | 40–54  |\n\nTheoretical max BST is **421**: peak at 100, three normals at 89, dump at 54. Getting there requires every random roll to land at its absolute ceiling. Three normals at 89 each need rand in [0.975, 1.0), roughly 2.5% per roll. The dump at 54 needs rand in [14/15, 1.0), about 6.7%. Combined with the 1% legendary roll and the right peak/dump assignment, the odds of a perfect 421 land around 1 in 6 billion. Within u32 space, but barely.\n\nThe ideal 421: debugging as peak (100), snark as dump (54), wisdom/patience/chaos all at 89.\n\n## Interaction Model\n\nBuddies work in two modes.\n\n**Passive**: the buddy watches your conversation with Claude and chimes in via speech bubble at key moments. Hit a tricky bug and it might encourage you or mock you, depending on its stats.\n\n**Active**: mention the buddy by name and its bubble responds directly. Claude steps aside.\n\nResponse style is attribute-driven. High snark delivers witty roasts. High patience offers comfort. High chaos is unpredictable. The buddy's system prompt is injected at generation:\n\n```\nA small {species} named {name} sits beside the user's input box\nand occasionally comments in a speech bubble. You're not {name} —\nit's a separate watcher.\n```\n\nClaude treats the buddy as an independent entity, yielding when the user addresses it directly.\n\n## The Mulberry32 PRNG\n\n```typescript\nclass Mulberry32 {\n  constructor(seed: number) { this.state = seed \u003e\u003e\u003e 0; }\n  nextU32(): number {\n    this.state = (this.state + 0x6d2b79f5) \u003e\u003e\u003e 0;\n    let t = (this.state ^ (this.state \u003e\u003e\u003e 15)) \u003e\u003e\u003e 0;\n    t = Math.imul(t, 1 | this.state) \u003e\u003e\u003e 0;\n    t = (t + (Math.imul((t ^ (t \u003e\u003e\u003e 7)) \u003e\u003e\u003e 0, 61 | t) \u003e\u003e\u003e 0)) ^ t;\n    return (t ^ (t \u003e\u003e\u003e 14)) \u003e\u003e\u003e 0;\n  }\n  nextF64(): number { return this.nextU32() / 4294967296; }\n}\n```\n\nPure bitwise math. Millions of evaluations per second.\n\n## buddydex\n\nThree interfaces, one shared engine. A Bun workspace monorepo with a CLI, a web UI, and a Claude Code plugin.\n\n## CLI\n\nRuns directly with `bunx buddydex` or installs globally via `bun add -g buddydex`.\n\nHunt for buddies matching your criteria:\n\n```bash\nbuddydex hunt --species dragon --rarity legendary\nbuddydex hunt --rarity legendary --perfect 70\nbuddydex hunt --shiny --tries 50000000\n```\n\nFilters include `--species`, `--rarity`, `--shiny`, `--min-stat chaos:90`, `--min-total 400`, and `--perfect` (every stat above a threshold). Default search space is 1M UUIDs.\n\nInject a result into `~/.claude.json`:\n\n```bash\nbuddydex inject \u003cseed\u003e\nbuddydex inject \u003cseed\u003e --preview\n```\n\nFirst injection backs up the original UUID. `buddydex restore` reverses everything.\n\n```bash\nbuddydex show       # current buddy\nbuddydex restore    # restore original from backup\nbuddydex roll \u003cid\u003e  # preview what a UUID produces\n```\n\n## Web UI\n\nLive at [buddydex.fun](https://buddydex.fun). A React + Vite app with the same engine running in a Web Worker. Uses `@zig-wasm/hash`, the same Zig Wyhash compiled to WASM. Results are identical to the CLI.\n\n## Slash Command\n\nRegistered as a Claude Code plugin:\n\n```bash\nclaude plugin add github:iammatthias/buddydex\n```\n\nAdds `/reroll` inside Claude Code. Claude handles argument parsing, search, result presentation, and injection within the conversation.\n\n## Notes\n\n**Bun is required for the CLI.** `Bun.hash()` uses Wyhash. The web UI gets the same results via `@zig-wasm/hash`.\n\n**UUID format is enforced.** The binary's UUID-to-BigInt parser crashes on non-hex input. The brute-forcer generates valid 8-4-4-4-12 format UUIDs only.\n\n**Auth is orthogonal.** `accountUuid` is read only for buddy generation. OAuth tokens handle authentication independently. Swapping the UUID affects nothing else.\n\n**Shared engine.** The `engine` package is an exact port of the deobfuscated binary logic: Wyhash, Mulberry32 PRNG, `rollBones`, and all the constants. Every interface uses it.\n\n## Project Structure\n\nBun workspace monorepo:\n\n```\npackages/\n  engine/    Shared core: Wyhash, Mulberry32, rollBones, constants\n  cli/       CLI tool: hunt, inject, restore, show, roll\n  web/       Web UI: React + Vite + Web Worker\n  plugin/    Claude Code integration: /reroll slash command\n```\n\n---\n\nThe best `/buddy` I have found so far is a `Legendary Snail`. It has as close as you can get to perfect stats, with the exception of `shiny`. \n\n![](blob://bafkreiaghtpei6oudr2froeg24hkjaw5gpaah667m5kely5l6yhwiv6fxi)\n\n`bunx buddydex inject d4a815e8-f9e4-4f20-84a3-2756508023bf`","tags":["ai","claude-code","reverse-engineering","tools"],"published":true,"createdAt":"2026-04-02T06:42:00Z","updatedAt":"2026-04-02T17:10:00Z"}
