Merge branch 'display' into 'master'
added some prints to correspond to the readme example See merge request mhart/DancingDroids!46
This commit is contained in:
commit
4f5fe016be
@ -247,6 +247,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let world: world::World = parse_config(raw_conf, &mut robot_pool)?;
|
||||
let mut hash: HashMap<robot::Position, u32> = HashMap::new();
|
||||
create_hash_map(&robot_pool, &mut hash);
|
||||
println!("World {{ x_max = {}; y_max = {} }}", world.x, world.y);
|
||||
robot::print_robots(&robot_pool);
|
||||
println!("Initial state");
|
||||
println!("==============");
|
||||
display_grid(&world, &robot_pool, &hash);
|
||||
|
21
src/robot.rs
21
src/robot.rs
@ -77,6 +77,27 @@ pub fn is_piouff(r: &Robot) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
/// Print robots id, position and instructions.
|
||||
pub fn print_robots(robot_pool: &Vec<Robot>) {
|
||||
println!("Robots [");
|
||||
for r in robot_pool {
|
||||
println!(
|
||||
"{{ id = {}, x = {}; y = {}; orientation: {}, instructions: {:?}, }},",
|
||||
r.id,
|
||||
r.p.x,
|
||||
r.p.y,
|
||||
match r.o {
|
||||
Orientation::N => "Norts",
|
||||
Orientation::S => "South",
|
||||
Orientation::E => "East",
|
||||
Orientation::W => "West",
|
||||
},
|
||||
r.i
|
||||
);
|
||||
}
|
||||
println!("]");
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
Loading…
Reference in New Issue
Block a user