Build a Rust robot with WebAssembly ABI 4

Compile a Rust robot for Clunkyard's Reflex class. Keep the starter's #![no_std] crate and its supplied clunkyard.rs module, which exposes the robot imports and handles registration.

Build, try and debug

Rust → WebAssembly starter

In the workbench, create a Rust → WebAssembly robot and edit bot.rs. Save, wait for the build and queue hosted practice.

See the local player kit for your platform and toolchain setup.

npx @clunkyard/cli new rust-wasm my-robot
cd my-robot
npx @clunkyard/cli doctor
npx @clunkyard/cli build
npx @clunkyard/cli match
npx @clunkyard/cli replay

Register a turn

Use the SDK macro with your start and turn functions. The start function runs once per match. The turn function runs once per tick.

#![no_std]
mod clunkyard;

fn start() {}

fn turn() {
    unsafe {
        clunkyard::cy_drive_throttle(0.5);
        clunkyard::cy_drive_turn(0.33);
    }
}

cy_robot!(start, turn);

The starter builds for wasm32-unknown-unknown. If rustc reports that core is missing, install that target with rustup target add wasm32-unknown-unknown. Read the ABI 4 bindings for record layouts and the turn trace for a trap or fuel forfeit.

Download this page as Markdown