惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

云风的 BLOG
云风的 BLOG
Security Archives - TechRepublic
Security Archives - TechRepublic
V
Vulnerabilities – Threatpost
C
CXSECURITY Database RSS Feed - CXSecurity.com
P
Proofpoint News Feed
G
GRAHAM CLULEY
P
Privacy International News Feed
The Hacker News
The Hacker News
Forbes - Security
Forbes - Security
U
Unit 42
N
News and Events Feed by Topic
D
Darknet – Hacking Tools, Hacker News & Cyber Security
C
Cyber Attacks, Cyber Crime and Cyber Security
C
Cisco Blogs
A
About on SuperTechFans
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
D
Docker
I
Intezer
Spread Privacy
Spread Privacy
The Last Watchdog
The Last Watchdog
V2EX - 技术
V2EX - 技术
S
Security @ Cisco Blogs
F
Full Disclosure
S
Secure Thoughts
M
MIT News - Artificial intelligence
Microsoft Security Blog
Microsoft Security Blog
G
Google Developers Blog
aimingoo的专栏
aimingoo的专栏
W
WeLiveSecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Project Zero
Project Zero
Recorded Future
Recorded Future
Cyberwarzone
Cyberwarzone
S
Security Affairs
AWS News Blog
AWS News Blog
H
Help Net Security
The GitHub Blog
The GitHub Blog
Hacker News: Ask HN
Hacker News: Ask HN
Vercel News
Vercel News
P
Proofpoint News Feed
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
The Register - Security
The Register - Security
S
Schneier on Security
F
Fortinet All Blogs
C
CERT Recently Published Vulnerability Notes
L
LINUX DO - 最新话题
T
Tor Project blog
T
The Exploit Database - CXSecurity.com
MongoDB | Blog
MongoDB | Blog
Webroot Blog
Webroot Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
I Built a Real-Time Zombie Outbreak Simulator Using Uber’s H3 Spatial Index and Web Workers
Mohid Dastge · 2026-05-20 · via DEV Community

There are two kinds of developers in this world:

1.Those who build practical, enterprise-grade, high-value CRUD applications.
2.Those who spend their weekends writing heavily optimized mathematical simulations calculating exactly how fast an army of fast-moving zombies would turn the city of London into an absolute buffet.

I fall squarely into the second camp.

I wanted to build a web-based, interactive zombie apocalypse simulator capable of handling thousands of distinct geographical zones in real-time at 60 FPS. No abstractions, no random generic circles expanding on a flat canvas—I wanted real-world city structures, actual road networks, weather vectors (wind directions), population densities, and dynamic 3D building reveals. Here is an engineering breakdown of how I combined Uber’s H3 Hexagonal Hierarchical Spatial Index, a custom SIZD mathematical epidemiological model, Web Workers for concurrent crunching, and an A road-network search algorithm* to build a highly responsive apocalypse sandbox.

The Core System Architecture: Separation of Church and Slaughter

If you try to run complex mathematical simulations for thousands of map coordinates directly on the browser's main UI thread, your application will freeze up faster than a civilian cornered by a zombie horde.To keep the UI running at a buttery-smooth 60 FPS, the app splits responsibilities cleanly between two distinct architecture layers:

┌────────────────────────────────────────────────────────┐
│               MAIN UI THREAD (Angular)                 │
│  - MapLibre GL Layer rendering & 3D Extrusions         │
│  - RequestAnimationFrame loops for particle tracers    │
├────────────────────────────────────────────────────────┤
                            │  ▲
        Worker Messages:    │  │ Worker Responses:
        { type: 'TICK' }    │  │ { type: 'TICK_RESULT', payload: ... }
                            ▼  │
┌────────────────────────────────────────────────────────┐
│            BACKGROUND WEB WORKER (TS)                  │
│  - Seeded Mulberry32 Pseudo-Random Number Generator    │
│  - Cellular H3 Neighborhood Math (gridDisk, gridRing)   │
│  - SIZD Differential Equations for cell metrics        │
└────────────────────────────────────────────────────────┘

Enter fullscreen mode Exit fullscreen mode

The background Web Worker manages the complete state of the simulation grid inside a lightweight Map layout (let grid: Map<string, SimCell>), processes data slices incrementally, and posts only lightweight updates back to the UI thread.

Deep-Dive Code Breakdown

Let's tear open the chest cavity of the code and analyze the exact algorithms and mathematics driving this apocalypse.
1. The Math Under the Hood: The SIZD Model

Traditional pandemic tracking models use the classic SIR Model (Susceptible, Infected, Recovered). But since zombies don't exactly "recover," we had to upgrade this to a custom SIZD Model inside calculations-worker.ts:

-Susceptible (Healthy civilians)

-Infected (Bitten, incubating, panicking)

-Zombie (Reanimated, hungry)

-Dead (Fully neutralized or consumed)

Every single cell on the map runs differential equation steps on every clock tick. Here is how the worker evaluates state transitions per cell:

const VARIANT_PARAMS: Record<ZombieVariant, VariantParams> = {
  standard: {
    gamma: 0.16, delta: 0.025, mu: 0.05, betaMult: 1.0,
    seedZombiePct: 0.06, seedInfectedPct: 0.12,
    pzZombiePct:   0.20, pzInfectedPct:   0.10,
  },
  fast: {
    gamma: 0.26, delta: 0.010, mu: 0.08, betaMult: 1.3,
    seedZombiePct: 0.08, seedInfectedPct: 0.15,
    pzZombiePct:   0.25, pzInfectedPct:   0.12,
  },
  horde: {
    gamma: 0.32, delta: 0.006, mu: 0.10, betaMult: 1.7,
    seedZombiePct: 0.14, seedInfectedPct: 0.22,
    pzZombiePct:   0.30, pzInfectedPct:   0.15,
  },
};

Enter fullscreen mode Exit fullscreen mode

gamma dictates the speed at which an Infected person turns into an active Zombie. Notice that in the horde configuration, conversion rates double (0.32), giving civilians almost zero time to get their affairs in order.
delta simulates humans fighting back. It is a zombie kill-rate coefficient. In horde mode, the sheer mass of numbers drops human defense efficacy down to a despair-inducing 0.006.

2. The Spatial Index: Uber's H3 Hex Grid

Using rectangular latitude/longitude blocks for mapping introduces severe distortion near the poles, and calculating distances using spherical trigonometry over thousands of points is incredibly slow. Instead, the simulation wraps cities into an elegant hexagonal grid using Uber's H3 spatial index.
Why hexagons?
Because unlike squares, every neighbor of a hexagonal cell shares an identical distance from its center point. This makes cellular automata wave propagation beautiful and simple.
Inside the worker loop, we handle the spread to neighboring areas using h3.gridDisk:

const ringSize = VARIANT_RING[variant];
const neighborIds = h3.gridDisk(cellId, ringSize).filter((id) => id !== cellId);

for (const neighborId of neighborIds) {
  const neighbor = grid.get(neighborId);
  if (!neighbor || neighbor.status !== 'clean') continue;
  if (neighbor.population <= 0) continue;

  const p = spreadProbability(cell, neighbor) * maturityFactor;

  if (rng() < p) {
    infectCell(neighbor, 0.005);
    dirtyCellIds.add(neighborId);
    spreadEvents.push({ fromCenter: cell.center, toCenter: neighbor.center });
  }
}

Enter fullscreen mode Exit fullscreen mode

The Maturity Gate & The Wind Matrix

To prevent the virus from looking like an unnatural, perfectly growing circle, I implemented two neat modifiers:

  1. Maturity Gate: Freshly infected cells have incubated the virus for fewer ticks, meaning they spread sluggishly. As a cell matures (maturity = Math.min(1, ticksInfected / 4)), its viral transmission probability maximizes (1.0), creating realistic pulsing waves of infection instead of a robotic uniform march.

  2. Deterministic Wind: When initializing the simulation, a pseudorandom direction vector (windAngle and windStrength) is calculated. The spread probability math incorporates this vector, pushing the outbreak along specific prevailing paths (e.g., chasing weather dynamics or structural layouts).

3. Simulating Chaos: Panic Flight Long Jumps

Real people do not sit quietly waiting for their hex cell to be overrun. They climb into cars, hit highways, and flee. This human behavior is modeled using Panic-Flight Long Jumps:

if (cell.status === 'overrun' && maturity >= 1 && hasTransit(cell)) {
  if (rng() < LONG_JUMP_BASE_P) {
    const jumpRing = 3 + Math.floor(rng() * 3); // Ring 3 to 5
    const candidates = h3.gridRing(cellId, jumpRing);
    if (candidates.length > 0) {
      const target = candidates[Math.floor(rng() * candidates.length)];
      const tgt = grid.get(target);
      if (tgt && tgt.status === 'clean' && tgt.population > 0 && hasTransit(tgt)) {
        infectCell(tgt, 0.003);
        dirtyCellIds.add(target);
        spreadEvents.push({ fromCenter: cell.center, toCenter: tgt.center });
      }
    }
  }
}

Enter fullscreen mode Exit fullscreen mode

If an infected hex reaches maximum maturity and sits adjacent to major transportation lines (hasTransit(cell)), it triggers a jump. The engine leaps over intermediate rings entirely using h3.gridRing(cellId, jumpRing), instantly creating isolated, non-contiguous cluster breakouts miles away from the primary containment zone.

4. Determinism: Mulberry32 Seeded PRNG

If a user shares a link to a simulation run, the recipient should witness the exact same chaotic sequence of events. Native Math.random() cannot handle this because it's completely non-deterministic. To solve this, the simulation implements a custom Mulberry32 pseudorandom generator inside the background thread:

createRng(seed: number): () => number {
  let s = seed;
  return () => {
    s |= 0;
    s = (s + 0x6d2b79f5) | 0;
    let t = Math.imul(s ^ (s >>> 15), 1 | s);
    t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
    return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
  };
}

Enter fullscreen mode Exit fullscreen mode

By passing down an explicit simulation seed integer, this fast, bitwise generator returns identical floating-point sequences every single time, giving us total reproducible control over the chaos.

5. Client Thread Optimization: Micro-routing with A* & Heaps

When an infection spreads from one cell to another, the UI draws a particle stream representing the civilian flight line. Drawing straight lines over real geometry looks terrible. Instead, map.ts intercepts these spread events and routes them along the city’s actual OpenStreetMap road network.To ensure the mapping stays completely performant, it uses an optimized A Routing Strategy* paired with a custom low-overhead Binary Min-Heap:

class MinHeap {
  private d: { id: number; f: number }[] = [];
  get size() { return this.d.length; }
  push(x: { id: number; f: number }) { /* O(log n) tree balancing bubble up */ }
  pop(): { id: number; f: number } | undefined { /* O(log n) bubble down */ }
}

Enter fullscreen mode Exit fullscreen mode

Instead of looping blindly through thousands of vertices across the whole city to locate the nearest intersection node, the application maps the node array indices into uniform coarse spatial coordinate boxes (nodeGrid) via a hashing utility:

function gk(lng: number, lat: number, s: number): string {
  return `${Math.floor(lng / s)},${Math.floor(lat / s)}`;
}

Enter fullscreen mode Exit fullscreen mode

This allows the lookup engine to query a constrained localized $5\times5$ tile region grid during its search (for (let dx = -2; dx <= 2; dx++)), shrinking node localization from a sluggish O(N) operation down to an instantaneous O(1) lookup.
Once localized, the A* paths are handed to MapLibre GL for rendering. If the distance exceeds an absolute boundary, the engine gracefully fallbacks to linear tracking, preventing long-distance jumps from eating valuable clock cycles.

6. Visual Trickery: 3D Building Extrusion Reveals

Uploading thousands of complete complex geometry features to GPU buffers on every frame causes noticeable stuttering. To avoid this, map.ts utilizes feature state binding.
When a city is loaded, every building is indexed into its respective H3 grid index cell using h3.latLngToCell at resolution level 9 (BUILDING_RES = 9).

dirtyCells.forEach((cell) => {
  const indices = this.buildingCellIndex.get(cell.cellId);
  if (!indices) return;
  const next = cell.status === 'overrun' ? 'overrun' : cell.status === 'infected' ? 'infected' : 'clean';
  indices.forEach((idx) => {
    this.map.setFeatureState({ source: 'city-buildings', id: idx }, { revealStatus: next });
  });
});

Enter fullscreen mode Exit fullscreen mode

By leveraging generateId: true on the GeoJSON layout, MapLibre assigns constant numerical IDs tracking index entries. When a hex vector updates, the system fires targeted setFeatureState updates only for the structural elements linked to that specific altered grid boundary.
MapLibre GL translates these state changes via data-driven styling expressions directly inside the GPU paint pipeline:

'fill-extrusion-height': [
  'match',
  ['coalesce', ['feature-state', 'revealStatus'], 'clean'],
  'overrun', 90,
  'infected', 45,
  3
]

Enter fullscreen mode Exit fullscreen mode

As a result, buildings dynamically "grow" from a baseline footprint height of 3 meters up to an ominous 90-meter crimson spire when completely overrun—handled entirely via high-speed GPU interpolation transitions, with zero data-reupload overhead!

What I Learned About High-Performance JavaScript

Avoid JSON serialization in loops: Do not pass thousands of deep objects over postMessage every 16ms. The background thread filters down to dirty cells only and caps visual spread tracers to small batches per tick.

GPU expressions are magic: Keeping your JS logic small and letting MapLibre's underlying shaders handle transitions (fill-extrusion-color-transition) keeps performance exceptionally light.

Hexagons rule the world: Square bounding coordinates make math tedious. Hex grids turn adjacent neighborhood discovery into a fast, fixed array query.

Try out the project here: Zombie-Outbreak

Please leave a star on the github repo if you liked what you saw.
Thanks.