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;
}
}
Do I use switch cases as well?
$\endgroup$