Skip to content
Snippets Groups Projects
Commit 1c9ab259 authored by Jan Uhlík's avatar Jan Uhlík
Browse files

Fix random grid generation.

Avoid creating obstacle on the same vertex where start/goal located is.
parent 6f398094
No related branches found
No related tags found
1 merge request!69Fix random grid generation
......@@ -54,19 +54,19 @@ RandomGridFactory::randomGrid(unsigned long height,
 
TGrid grid(height, width);
 
// Add nodes
ext::vector<node_type> obstacles;
// Generate start and goal node
node_type start(random_height(e1), random_width(e1));
node_type goal(random_height(e1), random_width(e1));
obstacles.push_back(start);
obstacles.push_back(goal);
// Generate obstacles
for (unsigned long i = 0; i < obstacle_cnt; ++i) {
node_type obstacle(random_height(e1), random_width(e1));
obstacles.push_back(obstacle);
// Try to avoid creating obstacle on place of start or goal vertex
if (obstacle == start || obstacle == goal) {
continue;
}
grid.addObstacle(std::move(obstacle));
}
 
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment