PR from MrHen

I rebased all of my changes from your master and merged any conflicts I saw. All tests are passing and things look good at a cursory glance.

There are massive refactoring changes in these commits so this PR is kind of a "pre-check" to get your feedback. One thing I noticed is that our IDEs are colliding on code styles so I will look into fixing the issue with something like [.editorconfig](http://editorconfig.org/).

As a quick explanation, I tried very hard to get the various AI pieces split into separate classes so they would be easier to test and/or replace/extend. I added a breadth first alternative as a proof-of-concept and am slowly expanding its test base in order to get it fully matching the default pattern. It currently has no impact on production behavior.