Random movement

Hello everyone. Very new here. I am looking for a way to script a random movement. Here is what I am looking for. I have a maze and my bad guy needs to move freely about the maze. When it reaches a wall I want it to turn randomly in another direction. When I thought I had it I got stuck in a corner. Can anyone help me with this?

Additional info:
When my good guy reaches a coin it sends the bad guy back to his starting position.
I got this to work. But I can't get my bad guy to move the way I want him to do to random twists and turns. I don't want his movements to become the same exact every time played. If this makes sense.

You could share the project, we all remix it, and you choose the one that works and give credit to whoever made it.

is how to turn randomly. But from what you say, you're getting stuck in a corner, and that means you're touching two walls at once and something's wrong with your program logic in that situation.

Please find this example. I hope it works as it is

The technique is to use several tiles, each defined by color of its center. Path is defined by a brown tile. Click on character to start.