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]
fn from_save(save: &Save) -> Sandbox
Construct a new Sandbox
with programs from the Save
.
fn step(&mut self)
Step each node through one instruction.
fn write_console(&mut self, value: isize)
Write a value to the console.
fn read_console(&mut self) -> Option<isize>
Read a value from the console.