Moved random AI algorithm to its own function

created randomAI function