[][src]Crate wasmdome_mech_sdk

Assembly Mechs: Beyond WasmDome SDK

The year is 2020 and our containerized civilization is falling apart. A cruel and villainous DevOps demon named Boylur Plait has descended from the cloud to Earth to challenge mankind to a tournament.

To win this tournament, Assembly Mechs must compete in an absurdly over-dramatized contest. These mechs will challenge their creator's ability to write code that will outlast and defeat everything that the demon and its nearly infinite hordes pit against us. Humanity's only hope is to master a technology called WebAssembly, win the tournament, and prove to the cloud nemesis that this world is well protected.

How to Play

The game is played by your mech declaring a handler function. During each turn, the mech's handler will be invoked and it will be responsible for returning a list of commands. These commands can include requests to move, fire a weapon, perform a radar scan, etc. Commands cost action points and you need to take care that you do not exceed the maximum number of action points per turn (currently 4).

Your mech will have to make clever use of the limited resources and information available to it to devise a strategy for winning the match.

The mech interacts with its environment exclusively through the use of the MechInstruments trait.

Possible Mech Actions

The following is a list of actions a mech can take by using the appropriate methods in the Assembly Mech SDK:

ActionAP CostDescription
move_mech1Moves the mech one grid unit in a given direction.
fire_primary2Fires the mech's primary weapon in a given direction. Primary weapons fire a single small projectile that will damage the first thing it encounters. Primary weapon range is available via sensor interrogation.
fire_secondary4Fires the mech's secondary weapon in a given direction. Secondary weapons fire an explosive projectile that damages the first thing it encounters, as well as producing splash damage that radiates out from the point of impact. Secondary weapon range is available via sensor interrogation.
radar_scan1Performs a full radar scan of the mech's surroundings, reporting on detected enemies and obstacles. The mech will receive the results of the scan at the beginning of the next turn.

The default, unaffected power of a mech is 4 units, meaning that within a single turn a mech may fire its secondary weapon once, move 4 times, or perform some other combination of actions. Accessing sensor values does not cost you anything.

Warnings

Take care not to exceed the maximum number of action points consumed in a given turn. At best, commands exceeding your power will fail, at worst (depending on the match rules) your mech might be penalized for the attempt

Collision damage is real, and your mech's hull will lose structural integrity when colliding with other mechs and with walls

Example

extern crate wasmdome_mech_sdk as mech;

use mech::*;

mech_handler!(handler);

// Respond to a request to take a turn
pub fn handler(mech: impl MechInstruments) -> Vec<MechCommand> {
    // Respond with up to 4 action points worth of actions
    vec![
        mech.request_radar(),
        mech.move_mech(GridDirection::North),
        mech.fire_primary(GridDirection::South),
    ]
}

Re-exports

pub extern crate wascc_actor;
pub extern crate wasmdome_protocol as protocol;

Macros

mech_handler

Declares the function to be used as the mech's turn handler

Structs

GameBoard

Represents the dimensions and other metadata for a game board. All game boards have an origin of (0,0) that starts in the bottom left (southwest) corner of the scene.

Point

A 2-dimensional coordinate within an arena

RadarPing

A single result from a radar scan. When a mech queries for the last radar scan and one is available, those results will be a vector of these radar pings

Enums

GridDirection

Represents all possible directions at the game engine resolution

MechCommand
RegisterOperation

An operation performed on a register

RegisterValue

Represents a value contained within a register. Note that not all registers support all value types

Constants

EAX

The primary accumulator register

EBX

The base register

ECX

The count register

Traits

MechInstruments

The interface through which a mech interacts with the arena. Functions on the mech instruments panel are divided into two categories: