AI functional with random logic. Added func docstrings.