Internal rewrite of ai_helper.get_attacks()

This is much faster than the previous version.  No change in
functionality.