In progress: implement attack optimization

This patch adds partial code for computing legal attack permutations
and ordering them on the basis of some strategy potentially defined by
the user.

At the moment this code is _not_ ready to roll and this patch is
really a [squashme] but as it isn't hooked into the repl by this patch
I'll let it slide.