Struct tis_100::machine::Sandbox [] [src]

pub struct Sandbox { /* fields omitted */ }

Implements the Simple Sandbox puzzle from the game.

Example

use tis_100::save::parse_save;
use tis_100::machine::Sandbox;

// This program reads the value from the console and simply passes it to the console output.
let src = "@1\nMOV UP DOWN\n@5\nMOV UP DOWN\n@9\nMOV UP RIGHT\n@10\nMOV LEFT DOWN\n";

let save = parse_save(src).unwrap();
let mut sandbox = Sandbox::from_save(&save);

sandbox.write_console(42);

for _ in 0..5 {
    sandbox.step();
}

assert_eq!(sandbox.read_console(), Some(42));

Methods

impl Sandbox
[src]

Construct a new Sandbox with programs from the Save.

Step each node through one instruction.

Write a value to the console.

Read a value from the console.