A method to score alignments such that the best alignment wins The mechanism to generate all possible alignments requires not much intelligence anyway, so that part we have already written for you. Your problem is the scoring mechanism. To score an alignment, we need to score every individual match and every gap that is introduced. Once nature decided on an indel, its length is less important, but longer indels are more difficult to make than shorter ones. Active site residues don't mutate.
Residues mutate more easily to residues encoded by similar codons.
Cysteines that sit in cysteine bridges don't mutate easily. Surface residues mutate more easily than core residues. Core residues mutate easier when they make fewer contacts. It is hard to mutate a glycine that sits somewhere with torsion angles that other residues cannot have. Scoring an alignment We have spent lots of time on amino acid similarity, and we have even used this knowledge in a rather sloppy manner to align some sequences.