Docs/Examples/Oracle Run

OracleRun (Autonomous Dungeon)

A permadeath dungeon crawl with escalating VRF-derived difficulty.


Overview

OracleRun is a permadeath dungeon that runs on an unchangeable schedule. Characters roll against VRF-derived difficulty each floor; survivors split the prize pool while dead characters are permanently flagged.

PropertyValue
Base contractAutoLoopVRFCompatible
VRF usageEvery tick (expedition resolution)
Gas per tick~114k (wipe) to ~137k (survivors)
Sourceautoloop/src/games/OracleRun.sol
Tests36 passing (unit + fuzz)

Why AutoLoop Is Structurally Required

  1. Mempool-snoop attack: a player-controlled trigger lets the caller compute the resulting VRF difficulty for their own character and only submit if favored. A neutral schedule fires for all characters simultaneously.
  2. Death-stalling: borderline characters want delay, strong characters want resolution now. No single trigger time serves both.
  3. Forfeit floor: the dungeon floor advances on survivor success. Player-controlled triggers could camp forever at low-difficulty floors.

Game Mechanics

  • Characters: minted at a fixed fee with initial power. Power determines survival odds.
  • Expeditions: characters register by paying an entry fee. When the expedition resolves, each character rolls keccak256(randomness, charId, "roll") % 1000. Survival requires roll + power > difficulty.
  • Difficulty: baseDifficulty + (currentFloor - 1) * difficultyPerFloor, capped at 999. The floor only advances when at least one character survives.
  • Permadeath: dead characters are permanently flagged. No resurrection in v1.
  • Prize pool: entry fees minus protocol rake, split equally among survivors. Full wipe sends the entire pot to the protocol.

Survival Math

survives = (roll + power) > difficulty
roll = keccak256(randomness, charId, "roll") % 1000
difficulty = baseDifficulty + (floor - 1) * difficultyPerFloor

With baseDifficulty=300, difficultyPerFloor=50, initialPower=400:

  • Floor 1: difficulty 300, survival if roll > -100 (always survives)
  • Floor 3: difficulty 400, survival if roll > 0 (99.9% chance)
  • Floor 7: difficulty 600, survival if roll > 200 (80% chance)
  • Floor 13: difficulty 900, survival if roll > 500 (50% chance)

Revenue Model

  • Character mint fees (100% to protocol)
  • 5% rake on every expedition entry pool
  • Full wipe rounds send entire pot to protocol (house edge)
  • AutoLoop gas fees on each resolution tick

Deploy

forge create src/games/OracleRun.sol:OracleRun \
  --constructor-args 10000000000000000 2000000000000000 60 500 300 50 400 \
  --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast

Args: characterMintFee, entryFee, expeditionInterval, protocolRakeBps, baseDifficulty, difficultyPerFloor, initialPower.

Dashboard

Play OracleRun on the AutoLoop Dashboard.