Back to blog

Can AI Solve a Maze? And Can You Make a Maze AI Can't Solve?

Pathfinding algorithms solve any perfect maze in milliseconds, while chatbots reading a maze picture are far less reliable. Here is why, and what that means if you want a maze that is hard for AI.

can ai solve a maze maze ai can't solve ai maze solver

“Can AI solve a maze?” sounds like one question, but it is really two. It depends on what you mean by AI, and on what form the maze is in. A pathfinding program working on the maze’s data and a chatbot looking at a picture of it are doing very different jobs, and they get very different results.

Short answer

  • Pathfinding algorithms solve every solvable maze, every time. Breadth-first search, depth-first search and A* are decades-old techniques that find a route through a maze stored as data in milliseconds. If a route exists, they find it. There is no maze with a valid path that they cannot solve.
  • Chatbots and image models are much less reliable. When a general-purpose AI model is shown a picture of a maze and asked to trace the path, it has to read the walls from pixels and then reason step by step about hundreds of corridors. Large mazes often trip them up: they may skip through a wall or claim a route that dead-ends. How well they do varies by model and changes as models improve, so treat any specific result as a snapshot.

So the honest answer to “can you make a maze AI can’t solve?” is: not one that a proper algorithm can’t solve. But you can make a maze that is genuinely hard for a chatbot looking at an image.

How computers solve mazes

To a program, a maze is a graph: each open cell is a node, and each gap between two cells is an edge. Solving the maze means finding a path between two nodes.

  • Breadth-first search (BFS) explores the maze in rings outward from the start and always finds the shortest route.
  • Depth-first search (DFS) follows one corridor as far as it goes, backs up at dead ends, and tries the next branch. It always finds a route, though not always the shortest.
  • A* is BFS with a sense of direction. It prefers cells that look closer to the goal, so it usually checks far fewer cells while still guaranteeing the shortest path.

On AI Maze Generator, A* is what draws the line when you press Show Solution, calculates the “optimal” step count in every game, and produces the answer pages in printable worksheets. For a 41×41 maze it takes a tiny fraction of a second.

There is also the well-known wall follower rule: keep one hand on the wall and keep walking. In a “perfect” maze (one with no loops), like every maze generated on this site, the wall follower always reaches the exit eventually, just not by the shortest route. Our guide to solving mazes covers this and other strategies people can use by hand.

Why a maze picture is harder for a chatbot

A language model does not run BFS on your maze. When you upload an image, the model has to:

  1. Read the walls correctly. Thin lines, small cells and image compression make it easy to miss a gap or see a wall that isn’t there.
  2. Keep track of where it is. Tracing a long route means holding many turns in mind without losing its place.
  3. Avoid confident shortcuts. Language models produce plausible-sounding answers, and a plausible maze route can still pass straight through a wall.

None of these problems exists for an algorithm that gets the maze as data. That is the whole gap.

A model that can write and run code can close that gap: it can turn the maze into a grid and run BFS on it. Then it solves the maze the same way any program would, as long as it reads the walls correctly in the first place.

Making a maze that is hard for AI (and fun for people)

If you want to challenge a chatbot, or simply give friends a tough puzzle, these settings help:

  • Go big. A 41×41 maze has far more junctions and dead ends than an 11×11 one. Pick the Expert size in the maze generator.
  • Share it as an image or on paper. A maze given as a picture has to be read before it can be solved. A printed PDF is hard for software and good for people.
  • Use a different shape. Hexagonal, circular and triangle mazes break the familiar square-grid pattern and are harder to read at a glance.
  • Limit what the player sees. In Fog of War you only see the cells around you, so you cannot plan the whole route from above. That is a real challenge for human players.

Keep in mind what does not help: you cannot make a maze impossible for a real solver as long as it has a path from start to finish. Every maze generated here is guaranteed to have exactly one solution, so any pathfinding algorithm will find it.

What about AI that generates mazes?

The same split shows up in the other direction. Image generators can draw something that looks like a maze, but they do not check that a path actually exists, so the result is often unsolvable. We wrote about this problem for tabletop players in why image AI fails at dungeon maps.

AI Maze Generator does not use an image model. It uses a randomized depth-first search to carve each maze and A* to solve it, so every maze is valid by construction. You can read how that works in our maze generation algorithms guide.

Try it yourself

Generate a maze, hide the solution, and see who finds the exit first: you, a friend, or your favourite chatbot. Then press Show Solution to check the answer against A*.