Consolidated AI base code into common prototype.