1
$\begingroup$

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'

Maze project

/* 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;
    }
}
$\endgroup$
3
  • $\begingroup$ what does this mean? Do I use switch cases as well? $\endgroup$
    – jsotola
    Mar 23, 2019 at 7:23
  • $\begingroup$ @jsotola its like switch(switchval) { case 1:, case 2 etc.. default } $\endgroup$ Mar 23, 2019 at 7:25
  • $\begingroup$ 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 $\endgroup$
    – jsotola
    Mar 23, 2019 at 7:44

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.