heavily refactored AI#guess