Search code examples
javadata-structuresmaze

How would I approach representing a "Thin-Walled" maze?


This

is representative of the type of maze I want to make. The walls don't occupy spaces, they just prevent you from moving between them. Since the walls aren't 2d tiles I don't think I'd use a 2d boolean array to represent it. I am not asking for help with how to generate a maze, just how to represent one of this type.


Solution

  • I have ended up going with 2 arrays, a (W+1)(H) array for vertical walls, and a (W)(H+1) array for horizontal walls. With this I can plug in a cell's coordinates and coordinates + 1 to get their adjacent walls. Now, I have one central place to get and set my wall data, so I don't worry about modifying cells stored wall values, like I would with the method described by QBrute & matt. I also think this is far more intuitive to use than having to abstract the maze into a thick walled one.