Cutebot Maze Code

I’m attempting to code microbit to use a cutebot to solve any maze. I understand the idea of maze solving algorithms but am having trouble coding it.

My biggest issue is having trouble getting the cutebot to turn the same amount each time. In the mazes I’ve tried so far, the algorithm should work but it tends to undershoot turning left and overshoot when it turns around. I also think it executes the nested If statements in ways that I wasn’t expecting - am I doing something wrong there?

Does anyone have any ideas of what I could do to improve my code?

Can you tell us a little more about how you were expecting the conditionals to run?

Also, you’re welcome to paste a link to your code. That will let forum members fiddle around with it a bit and try to help work out the issues.

Here’s a link to the code: https://makecode.microbit.org/S51678-00548-53437-51537

The idea was for the cutebot to move forward until it comes to a wall. Then, it should turn left and check for a wall after turning. If there is a second wall after turning left, I wanted it to turn round and restart the loop. If it did not see a wall, I wanted it to continue forward.

A big issue I’ve been having is getting the bot to turn at intervals of 90 degrees, and I think the logic of my conditionals is off.

Thanks!