source code :
while not initial position {
while there is no obstacle in front of us // not a new boundary {
start_boundary_x = x_position
start_boundary_y = y_position;
move(1s, forward)
end_boundary_x = x_position;
end_boundary_y=y_position;
registerInLinkedListAllPositions(start_boundary_x, start_boundary_y, end_boundary_x, end_boundary_y)
rotate_car(90, right)
if(boundary still there) {
rotate_car(90, left)
start_boundary_x=x_position;
start_boundary_y=y_position;
}
else { //the boundaries do not form a rectangle, it turns to the right
move(1s, forward)
if(there is an obstacle){ //the boundary turns slowly to the right, we already reached it
find_right_angle_obst() //we turn the robot to be in front of the boundary with a 90 degrees angle
rotate_car(90, left) //to be able to follow the boundary
}
else {
rotate_car(right) //it turned stronger
move(infinite, forward) //until we meet an obstacle
find_right_angle_obst()
rotate_car(90,left)
}
start_boundary_x=x_position;
start_boundary_y=y_position;
}
}
rotate_car(90,left) //change boundary
}
XMAX=findMaxX(linkedList)
YMAX=findMaxY(linkedList)
map=createMap(XMAX, YMAX, linkedList)