True Count
Game Engine Audit

Game Engine Audit

How we verify that True Count's blackjack engine is mathematically fair, rule-compliant, and statistically sound.

True Count treats blackjack as a skill game. Every hand is a problem to solve, and the app rewards playing it well. For that promise to mean anything, the engine behind the cards must be provably correct.

This section documents our game engine audit — a comprehensive, casino-grade verification suite modeled after the testing standards used by professional gaming laboratories like GLI, BMM, and eCOGRA.

Why Audit a Blackjack Engine?

When a player makes a decision at the table, they're trusting that:

  • The shuffle is truly random — no patterns, no bias, no predictability
  • The rules work exactly as described — dealer hits on the right totals, splits behave correctly, payouts match the stated odds
  • The math is fair — over thousands of hands, the house edge matches what published probability theory predicts for each table's rule set

Without verification, these are just claims. The audit turns them into evidence.

What Professional Labs Test

Our audit is structured around the same categories that organizations like Gaming Laboratories International (GLI-11) use when certifying casino software:

CategoryWhat It VerifiesWhy It Matters
RNG EvaluationThe shuffle algorithm produces uniformly distributed, uncorrelated cardsA biased shuffle makes the entire game unfair
Deck IntegrityEvery shoe contains exactly the right cards with no duplicates or gapsMissing or extra cards change the odds
Rule ComplianceDealer logic, player actions, settlement, and insurance all follow blackjack rulesA single rule error cascades through every hand
Payout AccuracyCredits awarded match mathematical expectations for every outcome typeRounding errors or formula bugs steal from players
Statistical FairnessObserved house edge, bust rates, and blackjack frequency match published theoryThe ultimate integration test — if any component is wrong, the numbers drift
Basic Strategy ValidationAll 280 strategy chart cells match published optimal playIncorrect hints teach players the wrong moves
Hi-Lo CountingCard counting math is accuratePlayers using the count peek feature need correct information
Round LifecycleEvery round completes correctly with bankroll conservationNo credits should appear or disappear during play

How It Works

The audit is a dedicated Swift test target (TrueCountEngineAudit) containing 76 tests across 8 categories. It runs two types of verification:

Deterministic tests use seeded shuffles to check every game rule exhaustively. These produce exact pass/fail results — there is no statistical margin. If the dealer should stand on soft 17 under S17 rules, the test verifies it for every possible hand total.

Statistical tests simulate hundreds of thousands of hands using basic strategy and compare the results against published mathematical expectations. These use chi-square goodness-of-fit tests, proportion tests, and correlation analysis with a significance level of alpha = 0.001 (99.9% confidence).

Configuration Matrix

Every test runs across all 5 dealer tables where applicable:

TableDecksBJ PayoutDASDouble RestrictionInsurance
Jean-Luc23:2YesAny two cardsYes
Czarita43:2YesAny two cardsYes
Jack63:2Yes9, 10, or 11 onlyYes
Lady Lux63:2No10 or 11 onlyNo
Aunty86:5No10 or 11 onlyNo

Statistical tests also run under both soft-17 rules (S17 and H17) for complete coverage.

The Tech Stack

  • PRNG: GKMersenneTwisterRandomSource (Mersenne Twister, period 2^19937-1)
  • Shuffle: Fisher-Yates algorithm with seeded deterministic replay
  • Framework: Swift Testing (@Test, #expect)
  • Dependencies: Zero external dependencies — Foundation and GameplayKit only

Category Details

1. RNG / Shuffle Evaluation

Tests the quality of card randomness using standard statistical methods:

  • Chi-square goodness of fit on rank and suit distributions across 100,000+ dealt cards
  • Serial correlation analysis at lag 1 to detect patterns between consecutive cards
  • Runs test on card color across independent shuffles
  • Inter-shuffle independence — the first card from shuffle N should be uncorrelated with the first card from shuffle N+1
  • Seed sensitivity — adjacent seeds must produce different shuffles
  • Edge case seeds — seed 0 and UInt64.max must produce valid, non-degenerate shuffles

2. Deck Integrity

Verifies the physical correctness of every shoe:

  • Every shuffle produces exactly deckCount x 52 cards
  • No card appears more than deckCount times (no duplicates)
  • Every rank-suit combination appears exactly deckCount times (no missing cards)
  • Cut card position matches the table's penetration setting
  • shouldReshuffle fires at exactly the right moment
  • Post-reshuffle shoes are complete and correct

Tested across 10,000 shuffles per deck count (1, 2, 4, 6, 8 decks).

3. Rule Compliance

Exhaustive deterministic verification of every game rule:

  • Dealer logic: Hits below 17, stands on hard 17+, S17/H17 soft-17 behavior, peek for blackjack on ace or ten-value upcard
  • Player actions: Hit, stand, double, split, and surrender availability across all table configurations, including DAS rules and double restrictions
  • Hand evaluation: Point values, hard/soft/best totals, multi-ace edge cases, blackjack detection (including split-hand exclusion), pair detection with ten-value normalization
  • Settlement: All outcome comparisons (player BJ vs dealer BJ, bust scenarios, total comparisons)
  • Insurance: Offered only on dealer ace at tables with insurance enabled, correct cost and payout math

4. Payout Accuracy

Tests every payout formula with multiple bet sizes (including odd values to verify truncation):

  • Blackjack at 3:2, 6:5, and 1:1 rates
  • Regular wins (2x), pushes (1x), losses (0), surrender (half, truncated)
  • Insurance cost (floor(bet/2)) and return (3x insurance bet)
  • Bankroll conservation: bankroll_before - wagered + returned = bankroll_after for every outcome

5. Statistical Fairness

The integration test of the entire engine — simulates real gameplay and checks the numbers:

  • Dealer bust rates by upcard compared against published Wizard of Odds probability tables
  • Blackjack natural frequency verified against the exact formula 2 * (aces/total) * (tens/(total-1))
  • House edge convergence over 500,000 hands per table using perfect basic strategy
  • Player outcome distribution (win/loss/push rates) compared to expected ranges

6. Basic Strategy Validation

Cell-by-cell verification of all three strategy charts against published Wizard of Odds multi-deck basic strategy:

  • Hard totals: 100 cells (10 player totals x 10 dealer upcards)
  • Soft totals: 80 cells (8 soft hands x 10 dealer upcards)
  • Pairs: 100 cells (10 pair types x 10 dealer upcards)
  • H17 overrides: Verifies exactly 3 cells differ from S17 (soft 18 vs 2, soft 18 vs A, soft 19 vs 6)
  • Surrender exclusion: Confirms the strategy engine never returns surrender (handled separately by table rules)

7. Hi-Lo Counting Verification

Deterministic checks of the card counting system:

  • Point values: 2-6 = +1, 7-9 = 0, 10-A = -1
  • Running count tracks correctly through known sequences
  • Full shoe deal always balances to RC = 0 (for all deck counts)
  • True count = running count / decks remaining (with 0.5-deck minimum clamp)
  • Player edge formula: -baseHouseEdge + trueCount * 0.005

8. Round Lifecycle Integrity

Full-round integration tests through RoundEngine:

  • Every started round reaches roundComplete (10,000 rounds per table)
  • Bankroll conservation holds for every round (including splits, doubles, and insurance)
  • Shoe reshuffles before exhaustion during continuous play
  • Split aces receive exactly one card each, cannot be hit further, and 21 is not blackjack
  • All phase transitions are valid (no illegal state machine paths)

Running the Audit

The audit is manually triggered — it never runs automatically in CI or as part of any automated pipeline. To run it:

cd TrueCountEngine && swift test --filter TrueCountEngineAudit

Execution time is approximately 2-3 minutes on Apple Silicon. All tests use fixed seeds for deterministic, reproducible results.

Audit Results

For the latest audit results with full test data and source code, see the Audit Report.

Reference Standards

This audit is informed by (but does not claim certification from) the following industry standards:

  • GLI-11 v3.0 — Gaming Laboratories International: Gaming Devices in Casinos (RNG and game math requirements)
  • GLI-19 v3.0 — Interactive Gaming Systems
  • NIST SP 800-22 — Statistical Test Suite for Random Number Generators
  • Wizard of Odds — Dealer outcome probabilities, house edge calculator, basic strategy charts

How is this guide?

On this page