Skip to content

Latest commit

 

History

History
75 lines (61 loc) · 1.23 KB

SPOILERS.md

File metadata and controls

75 lines (61 loc) · 1.23 KB

Spoilers

This file contains solutions for the tutorial.

Commented-out

#[no_mangle]
fn main() {
    loop {
        motor_wait();
        motor_step_fw();

        motor_wait();
        motor_step_fw();

        motor_wait();
        motor_step_fw();

        motor_wait();
        // motor_turn_right();
    }
}

Line-follower

#[no_mangle]
fn main() {
    loop {
        radar_wait();

        let scan = radar_scan_3x3();

        if scan.at(0, -1) == '.' {
            motor_wait();
            motor_step_fw();
        } else if scan.at(-1, 0) == '.' {
            motor_wait();
            motor_turn_left();
        } else if scan.at(1, 0) == '.' {
            motor_wait();
            motor_turn_right();
        }
    }
}

Enemy-stabber

#[no_mangle]
fn main() {
    loop {
        radar_wait();

        let scan = radar_scan_3x3();

        if scan.at(0, -1) == '@' {
            arm_wait();
            arm_stab();
        } else if scan.at(-1, 0) == '@' {
            motor_wait();
            motor_turn_left();
        } else if scan.at(1, 0) == '@' {
            motor_wait();
            motor_turn_right();
        } else {
            motor_wait();
            motor_step_fw();
        }
    }
}