I am attempting to implement an algorithm that creates a Maze using a Depth - First Search algorithm (like
this one). I have a two - dimensional array of Cell objects in a CellMatrix class. Each Cell holds a reference to a List<Cell> of its neighbors. Each cell also holds a reference to a Map which maps a direction (NORTH, SOUTH, EAST, WEST) to any of three conditions that can occur at a edge (WALL, PASSAGE, BOUNDARY). My current method is much longer than I usually like, and contains four if / else statements with what at first glance seems like a lot of code duplication (each if / else does basically the same thing). I know that many times these conditions can be alleviated through creative use of a Strategy (or Command)
pattern. but I'm at a loss to see how it could be implemented here.
Any help here would be greatly appreciated.
[ October 06, 2006: Message edited by: Garrett Rowe ]