0

maze

The problem i am having is the 2 pixel width pathways (the white parts).

In the top-left of the image (the darker black part) i have manually gone over the white parts that were 2 pixels in width/height;

there are two solutions (that i can think of).

  1. to programmatically edit it so that pathways are 1x1;
  2. to find a way of dealing with paths that are larger than 1x1.

any suggestions, the maze-solving algorithm (tremaux) i have implemented works for 1x1 pathways but i am trying to adapt it to this larger maze.

preferably looking for a solution that is adaptable to a maze where the pathway widths can be any size as i have already written a tool where i can take an image and turn it into a monochrome int[][] array for maze solving.

Just looking for hints/steps in the right direction since I'm not sure if I'm looking at this correctly or if I'm heading down the correct path (no pun intended).

Thanks

Community
  • 1
  • 1
Koborl
  • 235
  • 1
  • 11

3 Answers3

1

So your grid is effectively repeating (1,2) = 3 pixels, 1 wall 2 paths. Just remove every 3th row. Then remove every 3th column.

Rob Audenaerde
  • 19,195
  • 10
  • 76
  • 121
0

Think of the image as being divided up into 3x3 blocks, with the top-left corner being always wall, the top row and left column being the optional walls and the rest being path, like this:

W w w
w P P
w P P

W = always wall
w = possible wall
P = always path

You need to convert each of those 3x3 blocks into a 2x2 block like this:

W w
w P
samgak
  • 23,944
  • 4
  • 60
  • 82
0

If you're trying to thin the paths just to make the maze easier to solve, then you don't need to bother. Finding the shortest path through the maze with BFS is about as fast as any path thinning algorithm (except delete every Nth row and column), and will produce paths without any extra twists or turns.

Matt Timmermans
  • 53,709
  • 3
  • 46
  • 87