Friday, 25 September 2009

Doing some AI stuff in Perl

So, I've written a semi-automated Word Search Solver in perl over the last couple of days, I haven't uploaded the code to here, because I haven't found an adequate way of formatting the code yet (I sense another project coming up), but the post link should send you to the page on perlmonks where I uploaded to the post too, all of the details are there, but for completeness sake and to tantalize you into going there, I'm going to post the details here:

Description:
The code below is for a semi-automatic word search solver, that uses a recursive function to search a multi-dimension array containing the puzzle for the word that the user asks for.

The program is semi-autonomous, in that the search itself is carried out automatically, but the puzzle is (for the moment) hard-coded, and the user must enter each word that they want to search for one-by-one.

Interface:The interface is a simplistic text-based one, the user enters the word that they want to search for, and the program responds with a set of coordinates for the start and end positions of the word being searched for, or 'NO RESULT' if the word can't be found.
The only command available to the user apart from the search ability is the '#quit' command which exits the program.

Considerations: The program relies on the assumption that the dimensions of the grid to be searched are equivalent, i.e. rows == cols

Planned Improvements:
  1. The option for the user to enter in the puzzle data 'on the fly'
  2. Removal of the final global variable '@end'
  3. The ability for the user to define a list of values to search for
If that doesn't peak your interest then this probably isn't the sort of thing for you, but if you're interested in AI search techniques, solving word searches, variable references, or how to do any of the previous in perl, check it out.

No comments:

Post a Comment