{"slug": "i-asked-ai-for-christmas-snow-it-looked-fake-so-i-dug-up-my-college-math", "title": "I asked AI for Christmas snow. It looked fake, so I dug up my college math", "summary": "A developer tasked with adding falling snow to a mobile app's world map found that an AI agent's first attempt looked wrong—clumped flakes, a sky swaying as one curtain, and flakes popping back in on the same spot—and fixed it with five rules drawn from college math. The fixes include Poisson-disk sampling with size-scaled minimum gaps to break up clumping, per-size fade lines to create depth, one-way flake recycling, and per-flake random phase on a sine-wave sway so the sky no longer moves in unison. The rules, math and presets were packaged into a SKILL.md file so an AI agent can start from them instead of plain random placement.", "body_md": "*Short on time? Jump to the examples and the skill file at the end.*\n\nSo, winter's coming, and I got asked to make it snow on the world map in our mobile app. Cute little feature. I figured I'd ask my AI agent, tweak a couple of numbers and move on.\n\nThe snow showed up in about a minute. And it looked... wrong. Flakes bunched up in little clumps, the whole sky swayed left and right like one big curtain, and flakes faded out and popped right back in on the same spot. It took me a while to put my finger on why it bugged me so much.\n\nThen it clicked. This is the snow on basically every website: random x, random y, fall, jump back to the top. Everyone writes it that way, so of course the AI does too.\n\nI had a nagging feeling that some math from my college classes could fix it, so I went after the problems one at a time. Every demo below can be dragged, so go ahead and play with them.\n\nFirst thing that bugged me was the clumping. Turns out that's just what `Math.random()` does. Real randomness has clumps and holes, and our eyes read them as mistakes.\n\nThe fix even has a cool name: Poisson-disk sampling. You still drop flakes at random, but no two are allowed closer than a minimum gap. Drag the line and check out the circled pair.\n\nWay better. But the big flakes still sat side by side and looked like blobs, so I made the gap grow with size:\n\n`gap = base + extra × (radiusA + radiusB)`\n\nThe spacing was finally right, but every flake vanished at the same height, and the whole thing felt like a flat sticker on the screen. So I gave each size its own fade line. Small flakes disappear high up, big ones hang around longer, and suddenly there's a foreground and a background. You can move the lines for whatever you're dropping: light snow melts near the top, ash makes it all the way down.\n\nThis one drove me nuts. Fading out and back in on the same spot is a shortcut for looping, and once you notice it, you can't unsee it. The fix is almost boring: a flake that fades stays gone. It keeps falling where you can't see it and only comes back from the top.\n\nThis is where college math finally paid off. Each flake sways on a sine wave:\n\n`x = homeX + amp × sin(2π × t / period + phase)`\n\nIf every flake shares the same `phase`, the whole sky swings like it's hanging from one string. Give each flake its own random phase and they all drift on their own little schedule.\n\nFive small rules, and the snow finally looked like snow. That's where I should have stopped. Instead I started messing with the numbers. Make the flakes bigger, slower and petal shaped and you get cherry blossoms. Flip the speed negative and you get embers floating up from a fire. It's the same five rules every time, which still kind of delights me.\n\nI don't want to figure all of this out again next winter, so I wrote it down for future me. The five rules, the math and these presets are all in one file: [SKILL.md](https://gist.github.com/Telomelonia/5ac9676071c0eef6c3810f2224616caf). With it loaded, my AI agent starts from these rules instead of plain random. If someone's about to ask you for snow this December (they will), hand it to your agent first.\n\nAnd if Poisson-disk sampling got you curious, [Jason Davies' interactive explainer](https://www.jasondavies.com/poisson-disc/) is a beautiful rabbit hole.", "url": "https://wpnews.pro/news/i-asked-ai-for-christmas-snow-it-looked-fake-so-i-dug-up-my-college-math", "canonical_source": "https://dev.to/niatelom/i-asked-ai-for-christmas-snow-it-looked-fake-so-i-dug-up-my-college-math-e36", "published_at": "2026-11-25 11:07:34+00:00", "updated_at": "2026-11-25 11:12:49.610434+00:00", "lang": "en", "topics": ["artificial-intelligence", "ai-agents", "generative-ai", "ai-tools"], "entities": ["Jason Davies"], "also_reported_by": [], "takeaway": "Replacing plain Math.random() with Poisson-disk sampling, size-scaled minimum gaps, per-size fade lines, one-way recycling and per-flake sine phase makes AI-generated particle effects look natural instead of clumped and synchronized.", "recommendation": {"advice": "When an agent generates visual or procedural code, encode the domain rules in a skill file so it starts from proven constraints rather than naive defaults.", "playbook": "agent-architecture", "playbook_url": "https://wpnews.pro/playbooks/agent-architecture"}, "alternates": {"html": "https://wpnews.pro/news/i-asked-ai-for-christmas-snow-it-looked-fake-so-i-dug-up-my-college-math", "markdown": "https://wpnews.pro/news/i-asked-ai-for-christmas-snow-it-looked-fake-so-i-dug-up-my-college-math.md", "text": "https://wpnews.pro/news/i-asked-ai-for-christmas-snow-it-looked-fake-so-i-dug-up-my-college-math.txt", "jsonld": "https://wpnews.pro/news/i-asked-ai-for-christmas-snow-it-looked-fake-so-i-dug-up-my-college-math.jsonld"}}