# Cutebot Maze Code

**URL:** <https://forum.makecode.com/t/cutebot-maze-code/28776>\
**Category:** micro:bit\
**Created:** [May 16, 2024, 12:31am UTC](https://forum.makecode.com/t/cutebot-maze-code/28776 "2024-05-16T00:31:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jfuoco](https://avatars.discourse-cdn.com/v4/letter/j/47e85d/32.png) [@jfuoco](https://forum.makecode.com/u/jfuoco)\
**Post date:** [May 16, 2024, 12:31am UTC](https://forum.makecode.com/t/cutebot-maze-code/28776/1 "2024-05-16T00:31:01Z")

</div>

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?

 ![Screenshot 2024-05-15 4.25.34 PM](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/5/5526569f92b35bbef215559e49f6e4d8725e2196.png)

---

<div class="post-metadata">

**Author:** ![MakeCode](https://avatars.discourse-cdn.com/v4/letter/m/f475e1/32.png) [@MakeCode](https://forum.makecode.com/u/MakeCode)\
**Post date:** [May 16, 2024, 12:31am UTC](https://forum.makecode.com/t/cutebot-maze-code/28776/2 "2024-05-16T00:31:53Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jfuoco](https://avatars.discourse-cdn.com/v4/letter/j/47e85d/32.png) [@jfuoco](https://forum.makecode.com/u/jfuoco)\
**Post date:** [May 16, 2024, 4:30pm UTC](https://forum.makecode.com/t/cutebot-maze-code/28776/3 "2024-05-16T16:30:04Z")

</div>

Here’s a link to the code: [https://makecode.microbit.org/S51678-00548-53437-51537](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!
