added some prints to correspond to the readme example
This commit is contained in:
		
							parent
							
								
									3794e3e86a
								
							
						
					
					
						commit
						73232d2657
					
				| @ -247,6 +247,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { | |||||||
|     let world: world::World = parse_config(raw_conf, &mut robot_pool)?; |     let world: world::World = parse_config(raw_conf, &mut robot_pool)?; | ||||||
|     let mut hash: HashMap<robot::Position, u32> = HashMap::new(); |     let mut hash: HashMap<robot::Position, u32> = HashMap::new(); | ||||||
|     create_hash_map(&robot_pool, &mut hash); |     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!("Initial state"); | ||||||
|     println!("=============="); |     println!("=============="); | ||||||
|     display_grid(&world, &robot_pool, &hash); |     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 |     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)] | #[cfg(test)] | ||||||
| mod tests { | mod tests { | ||||||
|     use super::*; |     use super::*; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Volodymyr Patuta
						Volodymyr Patuta