Skip to main content

Deterministic Crit & Charge-Stage Lab

Prove via exact Markov-chain math why a 50% crit stat still tilts players with 5 consecutive misses in 55.2% of 50-swing runs, then test the 3 deterministic crit formulas from Zhaoshi Wulin live: linear charge-stage damage (5 + stages × 4), a dual-channel 100% crit gate (cards >= 2 || stages >= 3), and an independent 1.5x final multiplier (17 × 1.5 = 25) accelerated by 0-AP Sheath Focus.

CHARGING · NOT LOCKED YET
Next Hit: 9
Channel A: Cards
1 / 2 cards
Channel B: Stages
1 / 3 stages
⚔️ Converging Slash (Finisher)
base = 5 + 1 × 4 = 9
Deterministic Crit Formula X-RayZero-RNG Crit Contract
damage     = 5 + stages(1) * 4 = 9
crit_ready = (cards(1) >= 2) || (stages(1) >= 3) => FALSE
final_dmg  = crit_ready ? floor(9 * 1.5) : 9 => 9

Click "0-AP Sheath Focus" to charge both held blades to 3 total stages, then cast "Converging Slash" for guaranteed 17 × 1.5 = 25 Crit!

Math Proof: 5-Miss Streak in 50 Swings55.2%
50%50刀 (55.2%)0
50-Swing Sample: Max Miss Streak 4
100% Crit 0RNG Crit 0Miss 0
Roguelike Core Kit ->
01

Exact Markov-chain proof: 50% crit RNG suffers 5 consecutive misses in 55.2% of 50-swing runs

02

Formula 1 — Flat stage scaling: damage = 5 + stages × 4 (+5 upgraded), 3 stages = 17 predictable base

03

Formula 2 — Dual-channel 100% crit gate: (chargedCards >= 2) || (totalStages >= 3), zero coin flips

04

Formula 3 — Independent 1.5x final multiplier (17 × 1.5 = 25) + 0-AP Sheath Focus (+1 stage to 2 cards)

Installable Agent Skill · Free

Drop straight into Claude Code, Cursor, or Codex

Paste into your AI agent chat
Read https://gameskill.dev/labs/deterministic-crit/skill.md and apply this skill to my game
Go Deeper · Companion GameSkill Pro Kit

Companion pack "Roguelike Combat & Boss Kit" ships runnable JS/TS + Godot 4 (.gd) + Unity (.cs) source code — unlock all 12 multi-engine Pro packs + 84 commercial WAV SFX + 8 2D VFX shaders from $8.25/mo ($99/yr, save 36%) or $12.9/mo.

Full SKILL.md Specification & Verification Checklist

Deterministic Crit & Charge-Stage Finisher Contract

Raw 50% crit RNG feels rigged to players because human intuition underestimates streak math: across 50 independent attacks at 50% crit chance, the exact Markov-chain probability of suffering at least 5 consecutive non-crits is 55.2% (more than 1 in 2 runs!).

Replace coin-flip crit anxiety with player-controlled, 100% deterministic crits built on 3 hard formulas:

1. The 3 Mandatory Formulas

  1. Formula 01 — Replace Crit Chance with Linear Charge Stages:
    • Let players hold/charge cards across turns and compute flat base damage strictly from consumed stages: baseDamage = 5 + stages * 4 (or 5 + stages * 5 when upgraded).
    • Progression: 0 stages -> 5, 1 -> 9, 2 -> 13, 3 -> 17. Every investment yields an exact, calculable payoff.
  2. Formula 02 — Dual-Channel Guaranteed Crit Gate (OR Condition):
    • Lock 100% guaranteed crit (zero RNG roll) whenever EITHER threshold is met: crit_ready = (chargedCards >= 2) || (totalStages >= 3)
    • Channel A: Consume >= 2 charged cards (wide tempo route).
    • Channel B: Consume >= 3 total charge stages across held cards (tall focus route).
    • Two valid routes keep tactical flexibility high while guaranteeing zero dry-streak heartbreak on lethal finishers.
  3. Formula 03 — Independent 1.5× Final Multiplier + 0-AP Tempo Accelerator:
    • Multiply the post-stage base damage cleanly by an independent 1.5× crit bracket: finalDamage = crit_ready ? Math.floor(baseDamage * 1.5) : baseDamage
    • Example at 3 stages: floor(17 * 1.5) = 25 guaranteed crit!
    • Pair the finisher with a 0 AP tempo card (e.g. Sheath Focus / 并鞘蓄锋: +1 stage to 2 held cards at 0 cost) so players can assemble a full 100% crit lethal burst inside a single explosive turn.

2. Verification Checklist

  • Exact Markov-chain probability check confirms computeDryStreakProbability(50, 5, 0.5) === 55.2.
  • Base scaling returns 5, 9, 13, 17 for 0, 1, 2, 3 stages (5, 10, 15, 20 when upgraded).
  • crit_ready triggers true when (chargedCards >= 2) OR (totalStages >= 3) with zero random variance.
  • 3-stage finisher outputs exactly 25 (floor(17 * 1.5)) unupgraded and 30 (floor(20 * 1.5)) upgraded.
  • 0-AP tempo accelerator increments 2 held cards by +1 stage each (respecting per-card stage cap) without spending action points.

ENGINEERING BREAKDOWN & BENCHMARK

Why Naive AI Implementations Fail (Measured Benchmark)

True independent RNG (`rand() < 0.5`) feels rigged to human brains: across 50 attacks at 50% crit, there is a 55.2% chance of suffering a 5-hit non-crit dry streak. Pseudo-Random Distribution (PRD, `P(N) = C * N`) or deterministic charge counters eliminate frustrating streaks while preserving the exact long-term average.

Exact Markov math: 50% true RNG hits a 5-miss streak in 55.2% of 50-swing sessions vs 0% worst-case dry streak with deterministic charge cap.

PRODUCTION CODE · GODOT 4 · UNITY C# · TYPESCRIPT

Reference Implementation in Godot 4, Unity C#, and TypeScript

Godot 4 (GDScript)

prd_crit_system.gd
class_name PrdCritSystem
extends RefCounted

# Dota-style PRD constant C for ~25% effective crit (~0.08474)
var prd_c: float = 0.08474
var misses_since_crit: int = 0

func roll_crit(rng: RandomNumberGenerator) -> bool:
	misses_since_crit += 1
	var chance := minf(1.0, prd_c * float(misses_since_crit))
	if rng.randf() < chance:
		misses_since_crit = 0
		return true
	return false

Unity (C#)

PseudoRandomCrit.cs
using UnityEngine;

public class PseudoRandomCrit
{
    private readonly float _c;
    private int _attempts;

    // Example C values: 10% -> 0.01475, 25% -> 0.08474, 50% -> 0.30210
    public PseudoRandomCrit(float prdConstant = 0.30210f) => _c = prdConstant;

    public bool Roll()
    {
        _attempts++;
        if (Random.value < Mathf.Min(1f, _c * _attempts))
        {
            _attempts = 0;
            return true;
        }
        return false;
    }
}

TypeScript (Web / Phaser)

prd-crit.ts
export function solvePrdConstant(targetRate: number): number {
  let lo = 0;
  let hi = targetRate;
  for (let i = 0; i < 40; i++) {
    const mid = (lo + hi) / 2;
    let avgN = 0;
    let survive = 1;
    for (let n = 1; n <= Math.ceil(1 / mid); n++) {
      const p = Math.min(1, mid * n);
      avgN += n * survive * p;
      survive *= 1 - p;
    }
    if (1 / avgN < targetRate) lo = mid;
    else hi = mid;
  }
  return (lo + hi) / 2;
}

DEVELOPER FAQ

Tuning, Edge Cases & Engine Integration FAQ

What is Pseudo-Random Distribution (PRD) in games like Dota 2 and League of Legends?

Instead of a flat chance on every hit, PRD sets `P(N) = C * N` where `N` counts consecutive non-crits and `C` is solved so the average crit rate still equals the tooltip percentage—cutting extreme unlucky streaks dramatically.

When is a deterministic charge counter better than PRD?

In tactical roguelikes and deckbuilders where players plan around turn budgets, visible charge stages (e.g., 3 stacks = guaranteed crit) turn luck into a skill-rewarding combo resource.

Why does a 50% crit rate have a 55.2% chance of 5 misses in a row over 50 hits?

A single 5-miss window is only `1/32` (3.1%), but across 46 overlapping windows in a 50-swing fight, the cumulative streak probability climbs past 55%—making pure RNG feel broken.

Can I install this crit formula directly into Claude Code or Cursor?

Yes—use the `/labs/deterministic-crit/skill.md` one-line prompt above so your agent writes verified PRD or charge-stage crit logic with unit tests.

Related Engine Hubs, Guides & Production Kits

More interactive labs in this track

Extracted from a real game · Zhaoshi Wulin

Every formula in these labs ships inside our upcoming Steam wuxia deckbuilder

3 martial-arts characters, 39 enemies, 70 relics, 19 kungfu finishers built in Godot with AI agents. Every time we solve a hard design or feel problem, we turn it into an interactive lab and skill here.