Josh Cooper
, , ,
No Comments

A recursive pathfinding algorithm finds a path by growing & backtracking a path. You can’t evaluate multiple routes, you only have the one, and you explore it til you reach a dead end or the goal. So, how pray tell does one optimize a recursive pathfinding algorithm? The simple answer is instruction sets. If you […]

Josh Cooper
, , ,
No Comments

The problem is this: You have a two dimensional grid, and you need to scan the entire thing. Sure, but what does this ambiguous “scan” do? Well this particular post is about a word search puzzle, so the scans need to create strings to be used as search areas for the puzzle words. Scan the puzzle, and it compiles a list of all the columns, rows, and diagonals.

Now, there are a total of 8 directions you can scan a two dimensional grid by. { N, NE, E, SE, S, SW, W, NW – Exactly eight.} Wouldn’t it be nice if we didn’t need to scan all those directions. Well, if you think about it ‘E’ is a reflection of ‘W’ the same as ‘NE’ is a reflection of ‘SW’. Since the thing I just said, we don’t actually need to scan all 8 directions up front. We do need to look at all 8 directions, but we certainly don’t need to create strings for all 8.