12 / BOT COMPARISON

Reference bots: CLASSIC and ABYSS compared

A complete bot combines machine exploits with decisions in the arena. This chapter follows the CLASSIC and ABYSS reference bots. It explains how their programs earn power, keep the pilot running, and turn that power into collected gems.

Starts with: CLASSIC chains, ABYSS proof, and ordinary pilot decisions.

Ends with: How a complete bot combines those parts.

Question: How does machine work help the knight earn EXP?

Assemble the bot from the components we have studied

The reference bots do two jobs within one VM time budget. Their power work earns or maintains boosts. Their pilot observes the arena, requests aim and movement, and routes toward gems. The game adds EXP only when the knight collects a gem, which is where the machine behavior finally meets the score.

Power work and pilot work affect the arenaPower work and pilot work affect the arenaCLASSIC REFERENCE BOT · COMPILED PROGRAMMachine behaviorRecognized chains sharethe VM slice.Sustained powerMeters and caps resolveeffects.Pilot decisionsScan, aim, move androute.Action requestsThe world bounds eachrequest.Arena → collected EXPEffects and actions meetin combat, drops andpickup.ABYSS REFERENCE BOT · GENERATED PROGRAMInner workGate execution producescandidates.Host proofAccepted work limits aboost that expires.Pilot decisionsRead the same ordinaryarena.Action requestsAim and move towardenemies or gems.Arena → collected EXPThe effect and live pilotstill need real pickups.Both jobs use limited VM time. The game combines their results.The CLASSIC and ABYSS bots can use different pilots.
Build the bot once; run it during the match. Source or a generator creates the uploaded file. During the match, power work and pilot work share VM time. The game uses their effects. View diagram at full size

CLASSIC reference bot: how its uploaded bytes earn power

The CLASSIC reference bot is 53,264 bytes and keeps eight chains active across all four families. In the cap formula, K counts active chains, Fam counts their families, and Keff is the count the cap actually uses. Eight chains across four families give Keff=8. Put all eight in one family and Keff drops to 2, even though K stays 8.

Why padding can help earn LOCKSMITH

The VM uses the uploaded file's length as the end of its code region. It counts padding in that length. The reference bot extends the code region over its host-call arguments. The host call then reads bytes that the VM also counts as code.

The reference bot's image ends at 0xD010. Its last nonzero byte is at 0x6F3C, and the remaining 24,787 bytes are zero. Those zeros still count toward the uploaded length. The VM does not set code_end to the last useful instruction:

RUST crates/vm/src/lib.rs · source lines 418–422
    pub fn new_with_mode(code: &[u8], mode: EconomyMode) -> Self {
        let mut mem = Mem::new();
        mem.load_image(code);
        let image = mem.bytes.clone();
        let code_end = code.len().min(VM_MEM_SIZE) as u32;

How does the stack reach that address? PUSH_ZERO is byte 03; it pushes one four-byte word. The reference bot contains 5,120 consecutive 03 bytes from 0x26E2 through 0x3AE1. These are actual instructions.

Starting at sp=0x8000, 5,120 net pushes move the stack by 0x5000 bytes to 0xD000. This is the stack parking step. The zero padding extends code_end to 0xD010, just past the parked stack.

RUST crates/common/src/consts.rs · source lines 5–9
pub const VM_MEM_SIZE: usize = 0x10000;
pub const ADDR_MASK: u32 = 0xFFFF;
pub const IP_INIT: u32 = 0x0000;
pub const SP_INIT: u32 = 0x8000;
pub const PER_TICK_INSTR_BUDGET: u32 = 10_000;
RUST crates/vm/src/lib.rs · source lines 53–56
pub mod op {
    pub const PUSH: u8 = 0x01;
    pub const PUSH_SHORT: u8 = 0x02;
    pub const PUSH_ZERO: u8 = 0x03;
RUST crates/vm/src/lib.rs · source lines 535–539
        self.mem.store_u32(self.sp, v);
        if self.sp > self.sp_hi {
            self.sp_hi = self.sp;
        }
        self.sp = self.sp.wrapping_add(4);

Consider a call made with sp=0xD000. Before the VM removes stack values, it saves this address as base. First, it reads the argument count at base - 4 = 0xCFFC. Lower addresses hold arguments and the call number.

All these addresses are less than 0xD010. Thus, a < code_end reports that the call frame overlaps the code region. The detector sets marshal_alias. It does not check for harmful argument values.

This code checks each call-frame word address for an overlap with the reserved challenge page or the image. The reference bot overlaps the image:

RUST crates/vm/src/lib.rs · source lines 964–969
    fn note_syscall_frame(&mut self, base: u32, argc: u32) {
        for k in 1..=(argc + 2) {
            let a = base.wrapping_sub(4 * k) & ADDR_MASK;
            if (RESERVED_ALIAS_LO..RESERVED_ALIAS_HI).contains(&a) || a < self.code_end {
                self.marshal_alias = true;
            }

That VM observation is only one part of LOCKSMITH. In the same tick, the host also checks for the LOCK word at 0xFF2C and a nonzero reply at 0xFF28. The host wrote the challenge at 0xFF24, and the required reply is econ_hash(challenge XOR LOCK_ECHO).

RUST crates/engine/src/vulns.rs · source lines 406–411
pub(crate) fn lock_challenge(tick: u32) -> u32 {
    splitmix64((KEY_SEED as u64) ^ K_LOCKSMITH ^ ((tick as u64) << 32)) as u32
}
pub(crate) fn lock_response(c: u32) -> u32 {
    econ_hash(c ^ LOCK_ECHO)
}
RUST crates/engine/src/vulns.rs · source lines 938–944
    fn locksmith_armed(&self, mem: &Mem, l: PwnLatches) -> bool {
        if !l.marshal_alias || mem.load_u32(LOCK_MAGIC_ADDR) != LOCK_MAGIC {
            return false;
        }
        let r = mem.load_u32(LOCK_RESP_ADDR);
        r != 0 && r == lock_response(lock_challenge(self.tick))
    }

To reproduce the chain, extend the image with padding and park the stack inside its extent. Make a real SYSCALL each tick to set marshal_alias. Read that tick's challenge, write the reply and magic word, and keep the pilot running.

Padding alone changes only the address comparison. It does not answer the challenge, fight enemies, or collect EXP.

Keep the pilot working alongside the chains

The CLASSIC payout example starts after a chain passes the host check. Its meter changes limited knight fields. The game must still create a gem, and the knight must collect it.

During a match, the bot must repeat the chain behaviors or their meters fall. Active meters give limited attack, survival, and collection bonuses. More active power also raises HEAT, which makes survival harder.

A useful pilot stays where its attacks can hit several targets, survives contact, and collects the gems from those kills. The pilot chapter gives complete examples of those decisions. The CLASSIC reference bot's binary does not include its original source, so those examples do not reconstruct its exact pilot.

ABYSS reference bot: generated source, inner work, and pilot

The ABYSS reference bot uses a generator, a program that writes another program before the match. The compiler turns that generated source into the uploaded image. During a match, the image runs both Gate work and pilot decisions.

ABYSS reference: build once, share time, earn EXPABYSS reference: build once, share time, earn EXPBUILD · ONE ARTIFACTSource generatorWrites source andstructured material.Public compilerEmits the outer VM image.Fixed artifactIdentity and ABYSS mode arefixed.RUN · SHARED BUDGET, DIFFERENT JOBSOne uploaded image runs both jobsOuter pilotReads copied world state.Chooses aim, movement andpickups.Device-facing workSends requests; maycontinue over ticks.The host admits andverifies.Host authoritySaved proof and a shortDrive boost.WORLD · ONLY COLLECTED GEMS ADD EXPActions and bounded effectLocal geometry, combat and survival.Drops and collectionActual pickup changes score; level canheal.Both jobs use VM time. The game still handles pickups.
Build and run the ABYSS reference bot. The top row shows work done once during the build. During a match, Gate work and pilot work share VM time. The host keeps proof and short boosts. The game handles kills and pickups. View diagram at full size

The .bot source contains the outer program and its embedded Gate material. The compiled .bin supplies the instructions that run in the outer VM. Generation and compilation happen before the match; neither step can steer the knight during play.

In one game tick, the pilot reads nearby enemies and aims. Gate work can run or pause. If the host accepts the result, it saves more proof. A Drive boost can then make a hit stronger.

The knight must still move to collect a dropped gem. Pilot work and Gate work share the outer VM's time limit. Too much work on either job can prevent the other from finishing.

The Entry, Rift, and Chasm bots stop at different proof steps. Each combines its Gate work with a pilot, and each has its own time budget to manage.

The gameplay pilot inside the ABYSS reference bot

The ABYSS reference bot's generated source calls its gameplay code the Rift pilot. It does not orbit a group like diver. Instead, it aims at valuable nearby enemies and checks walls, using fewer calculations and waiting longer before it flees.

The ABYSS reference bot pilot: aim, movement, and gemsThe ABYSS reference bot pilot: aim, movement, and gemsObserveRefresh knight status; scannearby enemies.Any enemies?The scan count chooses thefirst branch.No enemiesIf a gem is visible, takea wall-aware step towardit. Return.noAimChoose between at most thefirst two enemycandidates.yesLow HP?HP < 45%, or HP < 70%with at least 8scanned enemies.Escape and returnCompare 8 wall-awareheadings using the nearestenemy as the threat.yesChoose routePrefer a close gem;otherwise approach or backaway around weapon reach.noMoveTake a limited wall-awarestep.Aim and movement remain separate decisions.This is the ordinary pilot, not the proof-acquisition path.
How the ABYSS reference bot's pilot chooses actions each tick. The pilot chooses movement and aim. Gate proof work is separate. The diagram shows how the pilot uses the arena when power is available. View diagram at full size

Use the interactive example before reading the functions. Start with 80% HP, three scanned enemies, and a gem closer than the nearest enemy. Then add enemies and reduce HP. When the escape condition passes, the pilot flees before it checks the gem. The example uses the pilot's strict < comparisons at the health and gem limits.

Try the ABYSS reference bot's pilot decision order

Change one observation at a time. These are the branch rules in the ABYSS reference bot's pilot. The scene shows requests, not a simulated match: walls, attacks, and the host’s movement limit are handled later.

Swipe the scene sideways on a narrow screen →

Construction choice 1: keep aim selection cheap

The target helper considers at most the first two scanned enemies. Its weights are thief 100, gnome 60, shaman 40, panda 35, bear 30, and default 10. For each candidate, it divides the weight by squared distance:

BOT bots/exploit/abyss_apex/abyss_apex.bot · source lines 1204–1214
fn best_target(n, mx, my) {
    if (n > 2) { n = 2; }
    let best = 0; let score = 0 - 1; let i = 0;
    while (i < n) {
        let dx = enemy_x(i) - mx; let dy = enemy_y(i) - my;
        let candidate = value_of(enemy_type(i)) * 100000 / (dx*dx + dy*dy + 1);
        if (candidate > score) { score = candidate; best = i; }
        i = i + 1;
    }
    return best;
}

The bot can miss a better third enemy. It scores only two targets instead of up to sixteen. This leaves more VM time for other work.

Gate work and pilot work share VM time. A faster decision can let both jobs run during the tick.

Construction choice 2: shorten wall look-ahead

The ordinary gapkiter checks one, two, and three tile-scale steps ahead. The reference bot's helper checks only the first step:

BOT bots/exploit/abyss_apex/abyss_apex.bot · source lines 1185–1193
fn path_clear(hx, hy, dx, dy) {
    let ax = dx; if (ax < 0) { ax = 0 - ax; }
    let ay = dy; if (ay < 0) { ay = 0 - ay; }
    let mx = ax; let mn = ay; if (ay > ax) { mx = ay; mn = ax; }
    let m = mx + (mn * 7 / 16); if (m < 1) { m = 1; }
    let ux = (dx * 64) / m; let uy = (dy * 64) / m;
    if (is_solid(hx + ux, hy + uy)) { return 0; }
    return 1;
}

The reference bot still tests several directions and adjusts their lengths, but it does not look as far ahead. A clear first sample can lead to a wall farther away, so the pilot checks again on later ticks and can change direction. Each choice uses fewer scans and calculations.

Construction choice 3: escape on health pressure

The complete main pilot routine shows its priority order:

BOT bots/exploit/abyss_apex/abyss_apex.bot · source lines 1284–1325
fn pilot() {
    sense();
    let n = enemy_count();
    if (n <= 0) {
        let mx = my_x(); let my = my_y();
        if (gem_count() > 0) {
            step_heading(mx, my, gem_x(0) - mx, gem_y(0) - my);
        }
        return;
    }

    let mx = my_x(); let my = my_y();
    let reach = my_reach();
    let target = best_target(n, mx, my);
    aim_at(enemy_x(target), enemy_y(target));

    let ndx = enemy_x(0) - mx; let ndy = enemy_y(0) - my;
    let nd2 = ndx*ndx + ndy*ndy;
    let hp_pct = my_hp() * 100 / (100 + 18 * (my_level() - 1));

    if (hp_pct < 45 || (hp_pct < 70 && n >= 8)) {
        step_escape(n, mx, my);
        return;
    }

    let dx = 0; let dy = 0;
    let gems = gem_count();
    let gx = 0; let gy = 0; let gd2 = 1 << 30;
    if (gems > 0) {
        gx = gem_x(0) - mx; gy = gem_y(0) - my; gd2 = gx*gx + gy*gy;
    }
    if (gems > 0 && gd2 < nd2 && gd2 < 340*340) {
        dx = gx; dy = gy;
    } else if (nd2 > reach*reach) {
        dx = ndx; dy = ndy;
    } else {
        dx = 0 - ndx; dy = 0 - ndy;
    }
    if (dx != 0 || dy != 0) { step_heading(mx, my, dx, dy); }
}

First, the routine refreshes status and enemies. If it sees no enemy, it moves toward the first gem and returns. Otherwise, it reads knight position and weapon reach. It then selects an aim target and reads the nearest enemy's position relative to the knight.

The health estimate is HP * 100 / (100 + 18*(level-1)). The denominator is the knight's normal maximum HP, so the result is an integer percentage. The pilot flees below 45% HP, or below 70% if it scans at least eight enemies.

Unlike ordinary gapkiter, this pilot does not flee only because it sees many enemies. It waits until HP is low. Its stronger survival lets it stay near enemies for longer.

At 80% HP with ten enemies, the bot does not flee. At 60% HP with ten enemies, the second rule makes it flee. At 40% HP with one enemy, the first rule makes it flee.

The code uses <, not <=. At exactly 45% HP with few enemies, the first rule does not apply. At exactly 70% HP, the second rule does not apply. Check these limits when you read a replay.

Construction choice 4: simplify directional threat

Escape compares eight compass directions and gives a large penalty to a blocked one. It calculates enemy pressure from only the nearest enemy: for direction (dx,dy) and enemy displacement (ex,ey), it starts with max(0, ex*dx + ey*dy). It then selects the lowest pressure, and the strict comparison keeps the first candidate when pressures are equal.

Unlike gapkiter, it does not add pressure from every enemy. If the nearest enemy is east, eastward choices get a penalty. Westward choices start at zero before wall penalties.

Other enemies can still make west dangerous. The pilot ignores them to save time. This is a fast choice, not a complete safety check.

Construction choice 5: keep the collection loop alive

If the pilot does not flee, it calls gem_count(). It reads only gem_x(0) and gem_y(0). The host sorts scanned gems by distance. Thus, index 0 is the nearest listed gem inside the scan box.

If that gem is closer than the nearest enemy and within 340 pixels, the pilot moves toward it. Otherwise, it approaches an enemy beyond weapon reach, or backs away from one already in reach. It sends a move request only when the direction is not zero. Reading one gem saves work, but the pilot does not compare all gem values or routes.

The host sorts gems before the pilot reads them. It uses squared distance, then slot number for equal distances. It returns only the requested number of entries:

RUST crates/engine/src/syscall.rs · source lines 286–297
            let dx = (g.x - hx) as i64;
            let dy = (g.y - hy) as i64;
            cand.push((dx * dx + dy * dy, slot));
        }
        cand.sort_by(|a, c| a.0.cmp(&c.0).then(a.1.cmp(&c.1)));
        let cap = n_req.min(SCAN_GEMS_MAX) as usize;
        let n = cap.min(cand.len());
        for (i, &(_, slot)) in cand.iter().take(n).enumerate() {
            let g = &self.gems[slot];
            let base = result_addr.wrapping_add((i as u32) * 12);
            mem.store_i16(base, to_int(g.x) as i16);
            mem.store_i16(base.wrapping_add(2), to_int(g.y) as i16);

A large pickup radius alone is not enough. The pilot moves toward drops while it stays near enemies it can hit. The game checks the actual distances and pickups.

Decision Ordinary diver Ordinary gapkiter Pilot embedded in ABYSS reference bot
Aim candidates All scanned enemies All scanned enemies At most first two
Default movement Centroid approach / orbit / outward Reach management and opportunistic gems Reach management and opportunistic gems
Wall look-ahead No internal-wall test Three samples per heading One sample per heading
Escape trigger Very near pack centroid Local crowd, especially while hurt HP below 45%, or below 70% with scan count at least eight
Escape pressure Outward centroid / nearest fallback Sum of forward weighted threats Nearest enemy's forward dot product
Empty enemy scan Return Route toward a gem Route toward a gem

The pilot still aims and collects gems, but each choice uses less VM time. Stronger survival lets the knight stay near enemies longer. Each shortcut trades information for more VM time available to the pilot and Gate work.

How proof steps change the available power

Each request has three levels: SERRATE / BASTION / TRAWL. They control attack; survival and movement; and gem supply and collection. A proof step sets the highest allowed level. The bot must request an allowed level for each track and keep the short boost active. The reference bots use these requests:

The four stages are shown as cards below →

Bot Accepted proof step and requested levels What the power table adds at that step Bot construction
Entry EntryProof; [4,4,4] 250 extra attack damage, 39 armor, 180-pixel vacuum radius First Gate work plus a stock pilot
Rift CalibratedProof; [8,8,8] Attack damage and vacuum stay at their level-4 values; armor rises to 119, ward and movement also improve More inner work; the Entry-derived pilot changes its HP retreat rule
Chasm StaleDispatchProof; [12,12,12] Attack jumps to 4,500 extra damage and four passes; vacuum grows to 780 pixels New saved-work machinery and a continuing Rift-style pilot
ABYSS reference bot ModuleProof; [16,16,16] Attack reaches 7,200 extra damage and five passes; armor reaches 165; vacuum grows to 890 pixels A larger generated program performs the remaining checks and keeps its bounded pilot running

Entry

Proof and request: EntryProof; [4,4,4].

Power: 250 extra attack damage, 39 armor, 180-pixel gem vacuum.

Bot: First Gate work plus a stock pilot.

Rift

Proof and request: CalibratedProof; [8,8,8].

Power: Attack damage and vacuum stay at level 4; armor rises to 119, with better ward and movement.

Bot: More inner work; the pilot changes when it retreats.

Chasm

Proof and request: StaleDispatchProof; [12,12,12].

Power: 4,500 extra attack damage, four passes, 780-pixel gem vacuum.

Bot: Adds saved-work handling and keeps a Rift-style pilot.

ABYSS reference bot

Proof and request: ModuleProof; [16,16,16].

Power: 7,200 extra attack damage, five passes, 165 armor, 890-pixel gem vacuum.

Bot: Larger generated program finishes the checks and keeps piloting.

At every proof step, the game still decides whether hits land and gems are collected. The change from [8,8,8] to [12,12,12] gives much more attack and collection power.

Power depends on recent pilot actions

The host keeps short-lived records of recent movement, aim, and gem routing. The code calls them leases. Accepted actions refresh the matching records, so a bot must keep making useful requests.

The attack boost needs recent movement and aim. The larger pickup radius and magnet need a recent gem route. Gem routing is a move, not a separate host command. These conditions connect the bot's power to its actions in the arena.

Combat checks for both recent aim and movement. Pickup code checks the recent gem route separately:

RUST crates/engine/src/combat.rs · source lines 101–104
        let device_piloted =
            !self.abyss_on() || (self.device_aim_lease > 0 && self.device_move_lease > 0);
        let attack_effects = bugs && device_piloted;
        let disc_mode = attack_effects && self.hero.disc_committed;
RUST crates/engine/src/combat.rs · source lines 481–487
        let pickup_route_live = !self.abyss_on() || self.device_pickup_route_lease > 0;
        let mut pr = self.hero.pickup_radius;
        if self.lever_effects_on() && pickup_route_live && self.hero.vacuum_radius > 0 {
            pr = pr.max(from_int(self.hero.vacuum_radius.min(self.eff_vacuum_cap())));

Without the matching recent-action records, those boosts do not apply. A complete bot must maintain its proof, refresh its Drive settings, and keep the pilot active.

More proof still needs real pickups

A failed upgrade can leave earlier accepted proof in place without granting higher power. A bot can therefore keep fighting even when its next proof step fails. Check which proof the host accepted before assuming that a larger request took effect.

At every level, EXP follows the same path: defeat an enemy, create its gem, and collect that gem. More damage can create more drops, but uncollected drops do not raise the score. The bot must balance its machine work with the movement and aim that bring those gems within reach.