AI now fully functional!  Need to work on edge cases, but the basic method is working!