July 30, 2015 Log No. 305

Recurse This

For once, a day with ample time to complete all the projects, and even tackle the bonuses! The GHOST word game and greedy implementation of “breaking and entering” seemed fairly straightforward to code, and we were able to make each of their methods very neat and efficient–either we’re getting better or today’s projects were somewhat easier.

With that done, we completed some of the bonus points for our GHOST game–adding a “Super Ghost” mode that allowed you to play the “harder” version (Wiki)–and then started on the Maze Solver bonus project. Didn’t quite finish that; we got the initial set up down, where we read a “maze” text file into a 2D array (after several days of doing this, I daresay we’re actually getting pretty speedy at that), but at end of day, was still stuck debugging the path-finding logic. I know it’s recursive, but as usual with recursion, I’m getting hung up on when exactly all the calls properly return, and what the initial call ends up receiving.

I figure the “end case” should be if it hits a node with no valid paths (i.e. all directions are either a wall or an already traversed node), in which case it returns its current position, to tack on to a path variable, which is, by that point, a path to that node, but then won’t the initial call to get_path return every series of paths in the game possible? So then am I supposed to return the path that contains/terminates at E, the end of the maze? Every time I get to recursion, always this same mindblock! With that being tomorrow’s topic, I guess I better reassure myself of the logic.

Leave a Reply

Your email address will not be published. Required fields are marked *