Recursive - see recursive

Gah. My code I was working on last night hit recursiveville, a place I try not to go unless the fate of the entire universe depends on it.

It's hard enough writing a recursive function that returns everything below it and everything below what's below, but trying to get a 'path' that only returns actual matches gets sticky.

I could brute force it, returning all paths, then simply matching any of the result sets, but that just feel hokey to me, and this is an exercise in stretching my brain to keep it in shape, not just get something done.

Here's what I'm doing. The Mrs. and I love to play both Scrabble and Boggle. Finding words in jumbles of letters is a simple yet satisfying game. I'm trying to write a Boggle like application that will allow us to run the game on separate computers (learning the communications channels between the apps is my main goal).

I've built the grid of letters, but now I need to be able to search through each letter, the letters that surround it for the next letter in line until the end of the attempted word is reached or no path is found. To make it a bit harder, you can't reuse letters that are already in your path and at any point there are up to 8 'paths' that may or may not work for you.

So, I want to be able to pass in an array of characters, find all the paths that match the first character and have an open path afterwards for the next, then loop back into that function, stripping off the first character and then seeing where the next paths are available. Remembering where I've been the whole time.

Oh. Then the $#^*& Qu problem rears its ugly head. Granted there are a few non-u following q words like qanun, qat, qabab, and qepig (An Azerbaijani unit of currency), but in Boggle the tile is always Qu. So, I have to display "Queen" but actually search for "Qeen". And if you type Q without a U I have to put one in there for you. Sounds easy until you realize the computer is pretty dumb and doesn't think about these kinds of things for you, you have to tell it every last thing.

It's good brain exercise. Yes, I know there are already games out there I could download or buy, but that's like saying there's already someone else at the gym so there's no need for me to work out.

posted by by Robb Allen @
Comments have been closed on this topic.