function to check if robot is in the map
This commit is contained in:
		
							parent
							
								
									4fc0f07e78
								
							
						
					
					
						commit
						2eaf624137
					
				
							
								
								
									
										14
									
								
								src/main.rs
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								src/main.rs
									
									
									
									
									
								
							@ -20,13 +20,15 @@ use std::io;
 | 
				
			|||||||
mod robot;
 | 
					mod robot;
 | 
				
			||||||
mod world;
 | 
					mod world;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
fn check_map(r: &robot::Robot, w: &world::World) -> Result<(), &'static str> {}
 | 
					/// Check if the robot is in the map.
 | 
				
			||||||
fn check_collisions(
 | 
					fn check_map(r: &robot::Robot, w: &world::World) -> Result<(), String> {
 | 
				
			||||||
    w: &world::World,
 | 
					    if (r.p.x, r.p.y) < (0, 0) && (r.p.x, r.p.y) > (w.x, w.y) {
 | 
				
			||||||
    r: &robot::Robot,
 | 
					        Err(format!("The robot {} is off map", r.id))
 | 
				
			||||||
    h: &collection::HashMap<robot::Position, u32>,
 | 
					    } else {
 | 
				
			||||||
) -> Result<(), &'static str> {
 | 
					        Ok(())
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// Parse the config file, generate the world and robot pool.
 | 
					/// Parse the config file, generate the world and robot pool.
 | 
				
			||||||
fn parse_config(conf: String, pool: &mut Vec<robot::Robot>) -> Result<world::World, &'static str> {
 | 
					fn parse_config(conf: String, pool: &mut Vec<robot::Robot>) -> Result<world::World, &'static str> {
 | 
				
			||||||
    let mut lines = conf.lines();
 | 
					    let mut lines = conf.lines();
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user