RNG System
Crimsonland uses a deterministic random number generator for spawns, bonus drops, perk selection, and various game events. Understanding the RNG helps predict and manipulate game outcomes.Random Number Generator
From the source code references, Crimsonland uses a custom RNG implementation: RNG Type:CrandLike (C stdlib rand-compatible)
Implementation: Located in grim.rand module
Characteristics:
- Deterministic: Same seed produces same sequence
- Reproducible: Replays use same seed for parity
- Fast: Optimized for frame-by-frame generation
Seed System
Seed Initialization: Game start, mode selection, or manual seed input Deterministic Replay: Survival mode replays use recorded seed to reproduce exact gameplay Seed Manipulation: Advanced players can use known seeds for specific outcomes (speedruns, challenges)RNG Applications
Creature Spawns
Spawn Template Selection:- Which spawn template (SpawnId)
- Creature tint (RGBA)
- Creature size (0.8x - 1.5x typical range)
- Movement speed (0.8x - 1.3x typical range)
- Heading direction (0 - 2π radians)
- Spawn position (screen edge location)
- Creature type (Zombie, Lizard, etc.)
- AI mode
- Flags (split on death, ranged attack, etc.)
Bonus Drops
Drop Chance Roll:| Bonus | Relative Weight | Rarity |
|---|---|---|
| Points | High | Common |
| Weapon | High (with Pistol) | Common |
| Fireblast | Medium | Common |
| MediKit | Medium | Medium |
| Shield | Low | Rare |
| Nuke | Very Low | Very Rare |
| Weapon Power Up | Low | Rare |
| Double XP | Low | Rare |
- Overall drop rate × 1.5
- Weapon bonus forced 75% of the time
Perk Selection
Selection Pool Generation:- Which perks appear in selection
- Order of perks displayed
- Perk effects (fixed per perk)
- Prerequisites (hard-coded)
- Mode availability (flag-based)
Combat RNG
Dodge Rolls (Dodger/Ninja perks):Spread and Accuracy
Projectile Spread:Visual Effects
Particle Systems:- Particle velocity variance
- Particle lifetime variance
- Particle rotation randomization
- Color tint variation
- Blood splatter positioning
- Decal rotation
- Decal scale variance
- Attack sound selection (attack_01 vs attack_02)
- Volume randomization
- Pitch variation
RNG Manipulation
Seed Control
Known Seed Benefits:- Reproducible runs (speedruns, verification)
- Favorable spawn patterns
- Perk selection guarantees
- Bonus drop optimization
Frame-Perfect Inputs
RNG Advancement: Each frame advances RNG state Input Timing: Slightly delayed input (1-2 frames) can change RNG state before perk selection Manipulation Strategy:- Know desired perk
- Delay level-up (kill enemies slower)
- RNG advances during delay
- Different RNG state = different perk pool
- Select perk when desired one appears
Bonus Manipulation
Bonus Spawn Timing:- Kill timing affects bonus rolls
- Multiple simultaneous kills = multiple rolls
- Spread kills over time for more attempts
Determinism and Replay
Replay System
Fromsrc/crimson/replay/ directory:
Replay Recording:
- Initial RNG seed
- Player inputs (frame-by-frame)
- Game mode and settings
- Restores exact RNG seed
- Replays inputs identically
- Reproduces exact game state
Desyncs
Causes:- Floating-point precision differences
- Code changes between versions
- Platform-specific RNG differences
- Timer/frame rate variance
RNG Patterns
Spawn Waves
Pattern Observation: Early game spawns follow rough patterns: Minutes 0-2: Mostly Zombies and basic Lizards Minutes 2-5: Mix of Zombies, Lizards, Spiders Minutes 5-10: Aliens appear, tougher variants Minutes 10+: Boss variants, all types, high density RNG Influence: Exact timing and mix randomized, but general progression follows patternBonus Clustering
Observed Behavior: Bonuses sometimes cluster (3-4 in quick succession) or drought (long gaps) RNG Explanation: Random distribution creates natural clusters and gaps Gambler’s Fallacy: Long drought doesn’t increase next drop chance (each roll independent) Actual Mechanics: Bonus Magnet provides second roll, but base rate unchangedStatistical Analysis
Expected Values
Dodger Perk (20% dodge):Variance
High Variance Events:- Fatal Lottery (binary outcome)
- Jinxed perk (random damage or benefit)
- Bonus drops (long droughts possible)
- Dodge rolls (frequent, averages out)
- Poison application (frequent, averages out)
- Spawn timing (minor variance)
RNG Trivia
Why Crimsonland uses deterministic RNG
Why Crimsonland uses deterministic RNG
Deterministic RNG enables:
- Exact replay functionality
- Fair speedrun verification
- Reproducible bug testing
- Parity between original and rewrite
RNG call frequency
RNG call frequency
At 60 FPS, Crimsonland calls RNG approximately:
- 10-20 times per frame (spawn checks, visual effects)
- 600-1200 times per second
- 36,000-72,000 times per minute
Speedrun seed manipulation
Speedrun seed manipulation
Speedrunners can use favorable seeds to guarantee:
- Early Plasma Rifle weapon drop
- Fastshot + Fastloader + Bloody Mess in first 3 levels
- No boss spawns in first 5 minutes
Related Documentation
- Perks - RNG-based perk selection
- Bonuses - Bonus drop RNG
- Creatures - Spawn template randomization
- Survival Mode - Spawn patterns
Source Code References
grim.rand- RNG implementationsrc/crimson/replay/- Replay system using deterministic RNGsrc/crimson/bonuses/selection.py- Bonus drop RNGsrc/crimson/perks/selection.py- Perk selection RNGsrc/crimson/creatures/spawn.py- Spawn template randomization