# Maze wall hugging both clockwise and anti-clockwise

So I did the algorithm for the vehicle to go in a clockwise direction(Refer to my pseudocodes below). But now that my school had said there will be an anti-clockwise direction as well, I'm not sure what to do. Do I only reverse the logic of my pseudocode below? Do I use switch cases as well? I'm not sure. So the vehicle must be able to move both clockwise and anti-clockwise around the 'maze'

/* Check if the left sensor is blocked*/
if(left sensor ==true )
{
if(Obstacle detected)
{
move_forward;
}
}
/* Check if the back-left sensor is blocked*/
if(back-left sensor ==true)
{
if(Obstacle detected)
{
move_diagonal_front_left;
}
}

/* Check if the front-left sensor is blocked*/
if(front-left sensor== true )
{
if(Obstacle detected)
{
move_diagonal_front_right;
}

}

/* Check if the front sensor is blocked*/
if(front sensor== true )
{
if(Obstacle detected)
{
move_right;
}

}

/* Check if the front-right sensor is blocked*/
if(front-right sensor== true )
{
if(Obstacle detected)
{
move_diagonal_back_right;
}

}

/* Check if the right sensor is blocked*/
if(right sensor== true )
{
if(Obstacle detected)
{
move_back;
}
}

/* Check if the back-right sensor is blocked*/
if(back-right sensor== true )
{
if(Obstacle detected)
{
move_diagonal_back_left;
}
else if(Obstacle cleared)
{
Move_backwards;
}
}

• what does this mean? Do I use switch cases as well? Mar 23, 2019 at 7:23
• @jsotola its like switch(switchval) { case 1:, case 2 etc.. default } Mar 23, 2019 at 7:25
• it is impossible to guess what changes you need to make to your code .... all i can suggest is that you check which side you are starting at and then follow the wall on the same side Mar 23, 2019 at 7:44