Heuristic Anti-Bot Detection in Browser Games: Timing Jitter, Canvas Fingerprints & Captcha Fatigue

By Blackwave · Category: Game Design & Anti-Cheat · PBBG Vault Forums


Nothing kills player motivation in a persistent browser game faster than automated macro bots. When human players realize that someone is running a headless Chrome script or an auto-clicker 24/7 to train gym stats, mine ores, or run crimes, legitimate players quit.

However, the standard cure is often worse than the disease: slapping a Google reCAPTCHA or Cloudflare Turnstile on every single action destroys player immersion and creates severe CAPTCHA fatigue.

Here is an architectural breakdown of how to build invisible, behavioral anti-macro heuristics into your game loops to detect bots silently before punishing them.


1. The Flaw of Traditional Fixed Delays

Amateur bot developers write scripts with fixed sleep timers:

// Dead giveaway: Fixed sleep
setInterval(() => {
    document.querySelector('#crime-button').click();
}, 2000); // Exactly 2000ms every time

Smart bot developers add random jitter:

// Smarter bot: Random jitter
function doCrime() {
    document.querySelector('#crime-button').click();
    setTimeout(doCrime, Math.random() * 1500 + 1000); // 1000ms to 2500ms
}

Does random jitter fool server-side statistical analysis? No. And here's why.


2. The Power of Statistical Standard Deviation & Gaussian Distributions

Human response times are not uniformly distributed.

  • A uniform random distribution (like Math.random()) generates an even rectangular frequency distribution where 1005ms is just as likely as 2490ms.
  • Human beings operate on a log-normal distribution. Human reaction times cluster around an average (e.g., 800ms) with a long tail stretching to 4,000ms (distraction, fatigue, alt-tabbing).

Server-Side Heuristic: Rolling Variance Check

Track the intervals between the last 50 actions on the player's session:

public function evaluateActionCadence(array $timestamps): float
{
    // Compute differences between consecutive actions
    $intervals = [];
    for ($i = 1; $i < count($timestamps); $i++) {
        $intervals[] = $timestamps[$i] - $timestamps[$i - 1];
    }

    $mean = array_sum($intervals) / count($intervals);
    
    // Calculate variance
    $variance = 0.0;
    foreach ($intervals as $interval) {
        $variance += pow($interval - $mean, 2);
    }
    $standardDeviation = sqrt($variance / count($intervals));

    // A human will have sporadic pauses (> 5s). A script with Math.random() has
    // an artificially bounded standard deviation and zero outliers.
    return $standardDeviation;
}

3. Detecting Headless Browsers Without Intrusive Captchas

Automated farm bots frequently run on headless browser environments (Playwright, Puppeteer, Selenium) to conserve RAM on cheap VPS servers. Headless environments leak telltale signals:

  1. navigator.webdriver flag: Evaluates to true by default in automated browsers unless patched.
  2. Missing Media Codecs: Headless Linux browsers often lack proprietary audio/video hardware codecs present on real consumer laptops.
  3. Zero Mouse Movement Events: If a player submits a form where the click coordinates are exactly {clientX: 0, clientY: 0} or occur without any preceding mousemove vector events, the action was triggered programmatically.

4. The Escalation Ladder (Never Ban Immediately)

Instant IP bans teach bot authors how to calibrate their scripts. Instead, use an escalating friction ladder:

flowchart TD
    A["Normal Play"] -->|Variance Anomaly Detected| B["Stage 1: Invisible Telemetry Flagging"]
    B -->|Consistent Anomaly Over 3 Hours| C["Stage 2: Micro-Delays & Decreased Drop Rates"]
    C -->|Bot Continues Unattended| D["Stage 3: Interactive Visual Minigame (Not Captcha)"]
    D -->|Failure / Ignored| E["Stage 4: Silent Shadow Jail"]

The Shadow Jail Strategy

Instead of locking the player out:

  • Let the bot continue running.
  • Silently zero-out cash gains and item drops.
  • Keep the bot busy wasting energy while preventing it from affecting the player market.
  • Review audit logs manually before permanent bans.

How Does Your Game Handle Bots?

What anti-cheat systems have you built into your game loops? Have you found effective ways to stop macroers without annoying real players? Let's trade notes below!