| This is a demo of a breadth first search algorithm in action. It is intended to be used for tower defense type games since it finds a path from every position to the goal. Thus it is only necessary to call the method once every time the map changes. The map is represented by a boolean array. In this case, a one dimensional array is used to speed up access times. Also, a one cell border is created to eliminate boundary checking which shaves off a few miliseconds from the algorithm. Note: Hold the control key when pressing "Find Paths!" to find paths with diagonals. This method is slightly slower though.. Also, you can draw tiles with the mouse and delete by drawing while holding the control key. |