jueves, 10 de septiembre de 2009

Mastermind in Perl

CPAN is an awesome repository of perl libs and apps. It's a bit like emacs plugins: Everything is there and, if not, you should rethink what you're doing because it's probably in a wrong direction.

I learned about MasterMind from a German friend and they called it 'SuperHirn'. When she taught me how to play I thought: "Hey, I bet I could write a Genetic Algo to play this thing". Lately, I've been looking for some toy project to hack in (preferably in perl). I've looked at making an installer for vectorlinux, or doing some crazy app to evolve classes using Io Language (I'll talk about this in another post).

I wanted it to be perl because I needed somewhere to apply what I learnt on YAPC::EU::2009. Things like autobox, Moose, extensive testing, Devel::Cover, PodCoverage, Perlcritic...

Then I decided to implement a MasterMind app in perl. It's clearly overengineered, because in CPAN there are already implementations for this in 200 lines (more or less). The thing is I wanted to review some MVC and OOP concepts I might have forgotten (too much blind hacking).

On the other side, I was kind of following JJMerelo's blog and twitter, and among many many amazing readings like His proposals for Undergrad projects (Really great ideas. In fact I've already read something about parasite computing, but again, that's for another post), I read that he just uploaded a code to play mastermind using Evolutionary Computation .

Now my next mission is finishing the code of the SuperHirn framework (I thought it as MVC, so I could write a GUI, or a CUI or even a web interface (if I ever learn Catalyst) ) and merge it with Merelo's code.

My current code is really messed up. Not well tested, and it doesn't even use Moose as it should be used, but it's my first experience with it so I'm already rewriting it as I implement the features.

Merelo++ for pushing me to write my code quicker (even without knowing it).

3 comentarios:

JJ dijo...

It's not playing using evolutionary algorihtms yet. Almost there (maybe in a few days), but so far only a sequential (test every combination in turn) and random (do it randomly) have been included. I have just uploaded to the other server code for Estimation of Distribution Algorithms (a operator-less form of EAs), which will be the first to be tested, as soon as I've got the time.
It will be great to have your code, and thanks for the collaboration.

Raimon Grau dijo...

I'll notify you when I have something working.

Btw, thank you for reading (at least some of) my posts. It's an honour being read by the master of feijoadic computing :)

JJ Merelo dijo...

An so far, one of the few practitioners. Too much gas, maybe... :-)
Cheers!